mirror of
https://github.com/micropython/micropython.git
synced 2026-01-05 19:50:30 +01:00
py/objdict: Fix __hash__ for dict_view types.
This adds a unary_op implementation for the dict_view type that makes the implementation of `hash()` for these types compatible with CPython. Signed-off-by: David Lechner <david@pybricks.com>
This commit is contained in:
committed by
Damien George
parent
8491eb190f
commit
2fe6d4eb86
@@ -18,4 +18,22 @@ try:
|
||||
except TypeError:
|
||||
print('TypeError')
|
||||
|
||||
# keys dict_view is not hashable
|
||||
|
||||
try:
|
||||
hash({}.keys())
|
||||
except TypeError:
|
||||
print('TypeError')
|
||||
|
||||
# values dict_view is hashable
|
||||
|
||||
print(type(hash({}.values())))
|
||||
|
||||
# items dict_view is not hashable
|
||||
|
||||
try:
|
||||
hash({}.items())
|
||||
except TypeError:
|
||||
print('TypeError')
|
||||
|
||||
# set operations still to come
|
||||
|
||||
Reference in New Issue
Block a user