Support slice hash (#5123)

* make slice object hashable

* Update test_slice.py from CPython v3.12

* remove TODO

* remove outdated tests
This commit is contained in:
ChenyG authored and GitHub committed 2023-11-25 13:11:17 +09:00
1 parent 8fc2c39d62
commit dc4f6994fb
3 files changed
+92 -16

No files matched your search

-10
View File
@@ -82,16 +82,6 @@ assert_raises(TypeError, lambda: slice(0) > 3)
assert_raises(TypeError, lambda: slice(0) <= 3)
assert_raises(TypeError, lambda: slice(0) >= 3)
# TODO: slice is hashable in CPython 3.12
# assert_raises(TypeError, hash, slice(0))
# assert_raises(TypeError, hash, slice(None))
#
# def dict_slice():
# d = {}
# d[slice(0)] = 3
#
# assert_raises(TypeError, dict_slice)
assert slice(None ).indices(10) == (0, 10, 1)
assert slice(None, None, 2).indices(10) == (0, 10, 2)
assert slice(1, None, 2).indices(10) == (1, 10, 2)