SystemError when compare with a mapping with broken length
serhiy-storchaka opened this issue · 0 comments
serhiy-storchaka commented
The following code:
from multidict import MultiDict
from collections.abc import Mapping
class BadMapping(Mapping):
def __getitem__(self, key):
return 1
def __iter__(self):
yield "a"
def __len__(self):
1 / 0
print(MultiDict(a=1) == BadMapping())
causes raising a SystemError:
Traceback (most recent call last):
File "<stdin>", line 7, in __len__
ZeroDivisionError: division by zero
The above exception was the direct cause of the following exception:
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
SystemError: <built-in method write of _io.TextIOWrapper object at 0x7f7d26f71d70> returned a result with an error set
Maybe it could even crash on debug build.