Message414583
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. |
|
Date |
User |
Action |
Args |
2022-03-05 15:52:43 | JelleZijlstra | set | recipients:
+ JelleZijlstra, larry, PythonF |
2022-03-05 15:52:43 | JelleZijlstra | set | messageid: <1646495563.41.0.269019710859.issue46930@roundup.psfhosted.org> |
2022-03-05 15:52:43 | JelleZijlstra | link | issue46930 messages |
2022-03-05 15:52:43 | JelleZijlstra | create | |
|