fix: restore EventEnum(value) lookup on Python 3.12+ - #207
Open
icedream wants to merge 1 commit into
Open
Conversation
Python 3.12 changed enum.EnumMeta.__call__ to raise TypeError when called on an aggregate Enum subclass that defines zero members of its own, before _missing_ is ever invoked. EventEnum is intentionally such a class (real event IDs live only on its subclasses: ChannelID, PluginID, etc), so pyflp.parse() was broken on Python 3.12+. Override _EventEnumMeta.__call__ to detect exactly that case (no args/ kwds, integer value, zero members on cls) and route to _missing_ directly, restoring pre-3.12 behaviour. All other lookups fall through to the normal enum machinery unchanged. Fixes demberto#183, demberto#201. Verified against the sample files attached to demberto#201 (FL Studio 25.1.3) as well as a small corpus of FL 11/12/24.2 projects.
icedream
marked this pull request as draft
September 8, 2026 04:59
icedream
marked this pull request as ready for review
September 8, 2026 05:18
icedream
force-pushed
the
fix/py312-enum-and-fl2026
branch
from
September 8, 2026 05:41
6ca068a to
2354fbf
Compare
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.
Same fix idea as #204.
Python 3.12 changed
enum.EnumMeta.__call__to raiseTypeErrorwhen called on an aggregate Enum subclass with zero members of its own, before_missing_is ever invoked.EventEnumis intentionally such a class, real event IDs only live on its subclasses (ChannelID,PluginID, etc). Sopyflp.parse()has been broken on Python 3.12+ since that release.This overrides
_EventEnumMeta.__call__to detect exactly that case (no positional/keyword args, integer value, zero members oncls) and route straight to_missing_, restoring pre-3.12 lookup behaviour. Every other call path (name-based construction, lookups on non-empty subclasses, etc.) falls through unchanged to the normal enum machinery.Fixes #183, #201.
Verified against:
empty.flp,untitled.flp, FL Studio 25.1.3.4922), both now parse cleanly (with the pre-existing, unrelatedVSTPluginEvent: Unknown marker 12warning on one of them).Disclaimer: AI assisted in writing this fix.