New submission from Miro Hrončok <m...@hroncok.cz>: I believe I found a regression in Enum in Python 3.10.0a5.
This is Python 3.9: >>> import enum >>> class C(enum.Enum): ... A = 0 ... B = 1 ... >>> C.A <C.A: 0> >>> C.B <C.B: 1> >>> C(0).A <C.A: 0> >>> C(0).B <C.B: 1> >>> The Enum instances can access class-attributes via dot, like normal instances do. While in Python 3.10.0a5: >>> import enum >>> class C(enum.Enum): ... A = 0 ... B = 1 ... >>> C.A <C.A: 0> >>> C.B <C.B: 1> >>> C(0).A Traceback (most recent call last): File "<stdin>", line 1, in <module> File "/usr/lib64/python3.10/enum.py", line 146, in __get__ raise AttributeError( AttributeError: C: no attribute 'A' >>> C(0).B Traceback (most recent call last): File "<stdin>", line 1, in <module> File "/usr/lib64/python3.10/enum.py", line 146, in __get__ raise AttributeError( AttributeError: C: no attribute 'B' In real word situations, it breaks meson: https://github.com/mesonbuild/meson/blob/398df5629863e913fa603cbf02c525a9f501f8a8/mesonbuild/backend/backends.py#L52-L78 The __str__ method does: if self is self.EXITCODE: ... And it fails with: AttributeError: TestProtocol: no attribute 'EXITCODE' This worked with 3.10.0a4. If this is a deliberate backwards incompatible change of behavior, I don't think it is documented in the changelog or what's new in Python 3.10, nor that it was deprecated in Python 3.9 and 3.8. ---------- components: Library (Lib) messages: 386626 nosy: hroncok priority: normal severity: normal status: open title: Enum regression: AttributeError when accessing class variables on instances type: behavior versions: Python 3.10 _______________________________________ Python tracker <rep...@bugs.python.org> <https://bugs.python.org/issue43162> _______________________________________ _______________________________________________ Python-bugs-list mailing list Unsubscribe: https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com