Repository navigation
Fix enum construction after registering an enum named type - #1612
Open
Rajatendu1 wants to merge 1 commit into
Open
Rajatendu1 wants to merge 1 commit into
Rajatendu1 wants to merge 1 commit into
Conversation
This branch has not been deployed
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Fixes #1519.
The original report identified that
EnumMetaregisters generated enums in module globals for pickling. An enum calledtypethen shadows Python's builtin and breaks subsequent enum construction.This patch follows the reporter's suggested
builtins.typeapproach at the two class-construction sites inEnumMeta.from_enum. It leaves the pickling registration unchanged. Three tests cover class syntax, functional construction and conversion from a Python enum, each followed by constructing another enum. The tests restore the module global afterward.Validation:
These are local Linux results. Benchmark timing was disabled for the clean baseline, final recheck and Python 3.10/3.13 suites; Python 3.8/3.9/3.11 and other operating systems were not tested. The fix is limited to the reported
typecollision, not a redesign of the module-global enum registry.AI assistance was used to prepare this patch, tests and description. The original diagnosis and suggested use of
builtins.typeare credited to the report in #1519 and its linked reproduction repository.