This issue tracker has been migrated to GitHub, and is currently read-only.
For more information, see the GitHub FAQs in the Python's Developer Guide.

Author JelleZijlstra
Recipients JelleZijlstra, PythonF, larry
Date 2022-03-05.15:52:43
SpamBayes Score -1.0
Marked as misclassified Yes
Message-id <1646495563.41.0.269019710859.issue46930@roundup.psfhosted.org>
In-reply-to
Content
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.
History
Date User Action Args
2022-03-05 15:52:43JelleZijlstrasetrecipients: + JelleZijlstra, larry, PythonF
2022-03-05 15:52:43JelleZijlstrasetmessageid: <1646495563.41.0.269019710859.issue46930@roundup.psfhosted.org>
2022-03-05 15:52:43JelleZijlstralinkissue46930 messages
2022-03-05 15:52:43JelleZijlstracreate