[issue38525] Strange reversed dict behavior
Serhiy Storchaka
report at bugs.python.org
Sat Oct 19 11:53:16 EDT 2019
Serhiy Storchaka <storchaka+cpython at gmail.com> added the comment:
The proposed fix fixes a crash, but there is other bug in iterating shared dicts.
class A:
def __init__(self, x, y):
if x: self.x = x
if y: self.y = y
a = A(1, 2)
print(list(iter(a.__dict__)))
print(list(reversed(a.__dict__)))
b = A(1, 0)
print(list(iter(b.__dict__)))
print(list(reversed(b.__dict__)))
With PR 16846 the last print outputs [] instead of expected ['x']. It crashes without PR 16846, so this issue is not only about empty dicts.
----------
nosy: +serhiy.storchaka
_______________________________________
Python tracker <report at bugs.python.org>
<https://bugs.python.org/issue38525>
_______________________________________
More information about the Python-bugs-list
mailing list