Message276801
Now, when compare errors raised during `in`, dict.keys(), dict.values() and set all propagate the errors. But dict.items() will swallow the errors(only key compare):
>>> class BadEq:
... def __hash__(self):
... return 7
... def __eq__(self, other):
... raise RuntimeError
...
>>> k1, k2, v1, v2 = BadEq(), BadEq(), BadEq(), BadEq()
>>> d = {k1: v1}
>>> k2 in d.keys()
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
File "<stdin>", line 5, in __eq__
RuntimeError
>>> v2 in d.values()
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
File "<stdin>", line 5, in __eq__
RuntimeError
>>> k2 in {k1}
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
File "<stdin>", line 5, in __eq__
RuntimeError
>>> (k2, v2) in d.items()
False
>>> (k2, v1) in d.items()
False
dictitems_contains.patch tries to fix this. |
|
Date |
User |
Action |
Args |
2016-09-17 15:25:42 | xiang.zhang | set | recipients:
+ xiang.zhang, vstinner, serhiy.storchaka |
2016-09-17 15:25:42 | xiang.zhang | set | messageid: <1474125942.74.0.117565832141.issue28189@psf.upfronthosting.co.za> |
2016-09-17 15:25:42 | xiang.zhang | link | issue28189 messages |
2016-09-17 15:25:42 | xiang.zhang | create | |
|