Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Enum: permission requested for backwards incompatible change that was already discouraged #80

Closed
ethanfurman opened this issue Oct 14, 2021 · 1 comment

Comments

@ethanfurman
Copy link
Member

In Python 3.5, due to a performance enhancement, it became possible to access one member from another:

class Color(Enum):
    RED = 1
    GREEN = 2
    BLUE = 3

>>> Color.RED.GREEN
Color.GREEN

This behavior has always been discouraged (from the docs):

Enum members are instances of their Enum class, and are
normally accessed as EnumClass.member. Under certain circumstances they
can also be accessed as EnumClass.member.member, but you should never do
this as that lookup may fail or, worse, return something besides the
Enum member you are looking for (this is another good reason to use
all-uppercase names for members)

The changes going in to 3.11 have finally enabled the removal of that behavior, and I am putting documentation-based deprecations in 3.9 and 3.10, but am unable to get code deprecations into the enum code base before 3.11.

Given that the behavior was never officially supported, may I change it in 3.11? It would raise an AttributeError, as it originally did in 3.4.

@warsaw
Copy link
Member

warsaw commented Nov 17, 2021

The Steering Council approves of this exception

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants