Fix Python 3.12 compatibility: EventEnum empty enum TypeError - #204
Closed
westclox-star wants to merge 1 commit into
Closed
Fix Python 3.12 compatibility: EventEnum empty enum TypeError#204westclox-star wants to merge 1 commit into
westclox-star wants to merge 1 commit into
Conversation
Python 3.12 changed EnumMeta.__call__ to raise TypeError when called on an enum with no members, before _missing_ is invoked. EventEnum has no members of its own (all live in subclasses), breaking parse() on Python 3.12+. Fix by overriding __call__ in _EventEnumMeta to route through _missing_ directly when the enum has no members. Fixes demberto#183
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.
Python 3.12 changed EnumMeta.call to raise TypeError when called on an enum with no members, before missing is invoked. EventEnum has no members of its own (all live in subclasses), breaking parse() on Python 3.12+.
Fix by overriding call in _EventEnumMeta to route through missing directly when the enum has no members.
Fixes #183 temporarily. IMO the lookup needs to change and I will attempt it in the future on my fork.