New submission from Fabian Zills <fabian.zi...@web.de>:

When iterating over __dict__ inside a classmethod, accessing __annotations 
causses RuntimeError: dictionary changed size during iteration.
This only seems to affect Python 3.10.x on a Ubuntu system.

The following can be used to reproduce this issue:

class ExampleCls:
    @classmethod
    def iter_cls(cls):
        for name, val in cls.__dict__.items():
            print(cls.__annotations__)


This can be fixed for this Example by calling  _ = cls.__annotations__ before 
iterating over the __dict__

----------
messages: 414582
nosy: PythonF
priority: normal
severity: normal
status: open
title: Iterating over cls.__dict__ in classmethod causes RuntimeError when 
printing __annotations__
type: crash
versions: Python 3.10

_______________________________________
Python tracker <rep...@bugs.python.org>
<https://bugs.python.org/issue46930>
_______________________________________
_______________________________________________
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com

Reply via email to