diff options
author | David Lechner <david@lechnology.com> | 2023-01-12 19:51:45 -0600 |
---|---|---|
committer | Damien George <damien@micropython.org> | 2023-05-19 12:06:06 +1000 |
commit | 8491eb190f2ea27f113c0cc7c0e619807a84f7ed (patch) | |
tree | bcd942be0d98eb80209d2028c673e7cfa7e5f54d /tests/basics/slice_op.py | |
parent | eaccaa36771f784dfb458b8ba3591f11513824e6 (diff) |
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>
Diffstat (limited to 'tests/basics/slice_op.py')
-rw-r--r-- | tests/basics/slice_op.py | 15 |
1 files changed, 15 insertions, 0 deletions
diff --git a/tests/basics/slice_op.py b/tests/basics/slice_op.py new file mode 100644 index 000000000..f1e83c5e2 --- /dev/null +++ b/tests/basics/slice_op.py @@ -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') |