py/objslice: Ensure slice is not hashable.

As per https://bugs.python.org/issue408326, the slice object should not be
hashable.  Since MicroPython has an implicit fallback when the unary_op
slot is empty, we need to fill this slot.

Signed-off-by: David Lechner <david@pybricks.com>
This commit is contained in:
David Lechner
2023-01-12 19:51:45 -06:00
committed by Damien George
parent eaccaa3677
commit 8491eb190f
2 changed files with 22 additions and 0 deletions

15
tests/basics/slice_op.py Normal file
View File

@@ -0,0 +1,15 @@
try:
t = [][:]
except:
print("SKIP")
raise SystemExit
# REVISIT: slice comparison operators are not implemented in MicroPython
# test that slice is not hashable, i.e. it can't be used to copy a dict
try:
{}[:] = {}
except TypeError:
print('TypeError')