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 hroncok
Recipients hroncok
Date 2021-02-08.12:22:59
SpamBayes Score -1.0
Marked as misclassified Yes
Message-id <1612786979.73.0.896348338765.issue43162@roundup.psfhosted.org>
In-reply-to
Content
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.
History
Date User Action Args
2021-02-08 12:22:59hroncoksetrecipients: + hroncok
2021-02-08 12:22:59hroncoksetmessageid: <1612786979.73.0.896348338765.issue43162@roundup.psfhosted.org>
2021-02-08 12:22:59hroncoklinkissue43162 messages
2021-02-08 12:22:59hroncokcreate