class C:
def __init__(self, x):
self.x = x
def __eq__(self, other):
return self.x == other.x
def __hash__(self):
return 'strings are not allowed'
c = C(5)
s = set()
print(C(5) in s)
When this code is run in Python 3.12, it raises an exception:
Traceback (most recent call last):
File "test.py", line 14, in <module>
print(C(5) in s)
^^^^^^^^^
TypeError: __hash__ method should return an integer
When this code is run in Python 3.12, it raises an exception:
In Brython, the code runs without error.
Thanks for taking a look!