Jelle Zijlstra <[email protected]> added the comment:
Can reproduce this:
>>> ExampleCls.__dict__
mappingproxy({'__module__': '__main__', 'iter_cls': <classmethod(<function
ExampleCls.iter_cls at 0x7f1742669d80>)>, '__dict__': <attribute '__dict__' of
'ExampleCls' objects>, '__weakref__': <attribute '__weakref__' of 'ExampleCls'
objects>, '__doc__': None})
>>> ExampleCls.iter_cls()
{}
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
File "<stdin>", line 4, in iter_cls
RuntimeError: dictionary changed size during iteration
>>> ExampleCls.__dict__
mappingproxy({'__module__': '__main__', 'iter_cls': <classmethod(<function
ExampleCls.iter_cls at 0x7f1742669d80>)>, '__dict__': <attribute '__dict__' of
'ExampleCls' objects>, '__weakref__': <attribute '__weakref__' of 'ExampleCls'
objects>, '__doc__': None, '__annotations__': {}})
The descriptor for type.__annotations__ writes a new attribute into the class's
dict if it doesn't exist yet. This was done in bpo-43901 / GH-25263.
I don't see a way to fix this bug while preserving the behavior bpo-43901 was
aiming for.
----------
nosy: +Jelle Zijlstra, larry
_______________________________________
Python tracker <[email protected]>
<https://bugs.python.org/issue46930>
_______________________________________
_______________________________________________
Python-bugs-list mailing list
Unsubscribe:
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com