Repository navigation
[3.12] EnumMeta.__getattr__ removed without deprecation #106762
Description
Activity
- addedtype-bugAn unexpected behavior, bug, or errorAn unexpected behavior, bug, or error
on Jul 15, 2023 - addedstdlibStandard Library Python modules in the Lib/ directoryStandard Library Python modules in the Lib/ directory3.12only security fixesonly security fixes3.13only security fixesonly security fixes
on Jul 15, 2023 It's actually
EnumMeta.__getattr__, but yes, it needs to be removed from the documentation as well as having a news entry.- changed the title
[-][3.12] `Enum.__getattr__` removed without deprecation[/-][+][3.12] `EnumMeta.__getattr__` removed without deprecation[/+]on Jul 15, 2023 jacobtylerwalls commented
on Jul 15, 2023 ContributorAuthorMore actionsIt was the original method of looking up enum members, but it was quite slow; a more performant method is being used now.
Do you have a situation where
__getattr__was being directly called?jacobtylerwalls commented
on Jul 17, 2023 ContributorAuthorMore actionsYes, I found it when trying to pass the pylint test suite against Python 3.12. Apparently the presence of a
__getattr__attribute is used as a heuristic for whether dot-access syntax is permitted, so pylint's linting of enums will have false negatives without a patch.Do you have a situation where getattr was being directly called?
So, not called directly, but more like
if getattr(EnumClass, "__getattr__"):A deprecation period would give just a little more runway to deal with that, but the patch probably isn't particularly involved.
jacobtylerwalls commented
on Jul 17, 2023 ContributorAuthorMore actionsWhat about just keeping
__getattr__as a shim for__getitem__?Where is
has_dynamic_getattrdefined? Is it just looking for presence, or something more?jacobtylerwalls commented
on Jul 17, 2023 ContributorAuthorMore actionsIt's in an upstream dependency
astroid. Here'shas_dynamic_getattr: I'm fairly certain it just checks for presence. (When it callsself.getattr, it's checking for the presence of an entry inself.locals, where self is astroid's version of the ast node for the class, and locals is the set of names defined on the class, like this):# python 3.11 (Pdb) self <ClassDef.Color l.2 at 0x106fb0910> (Pdb) self.metaclass() <ClassDef.EnumType l.468 at 0x1072c9450> (Pdb) '__getattr__' in self.metaclass().locals True
jacobtylerwalls commented
on Jul 22, 2023 ContributorAuthorMore actionscc/ @Yhg1s to put on your radar for rc1.
Metadata
Metadata
Assignees
Labels
Projects
- StatusShow more project fieldsDone
Bug report
3.11
3.12b4
I see that
__getattr__is documented, so I would have expected either a deprecation notice or an entry in What's New for Python 3.12.Linked PRs
EnumMeta.__getattr__removal #107466EnumMeta.__getattr__removal (GH-107466) #107509