Skip to content

fix: restore EventEnum(value) lookup on Python 3.12+ - #207

Open
icedream wants to merge 1 commit into
demberto:masterfrom
icedream:fix/py312-enum-and-fl2026
Open

fix: restore EventEnum(value) lookup on Python 3.12+#207
icedream wants to merge 1 commit into
demberto:masterfrom
icedream:fix/py312-enum-and-fl2026

Conversation

@icedream

@icedream icedream commented Sep 8, 2026

Copy link
Copy Markdown

Same fix idea as #204.

Python 3.12 changed enum.EnumMeta.__call__ to raise TypeError when called on an aggregate Enum subclass with zero members of its own, before _missing_ is ever invoked. EventEnum is intentionally such a class, real event IDs only live on its subclasses (ChannelID, PluginID, etc). So pyflp.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 on cls) 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:

  • The two sample files attached to 🐞 tryinng to load flp errors #201 (empty.flp, untitled.flp, FL Studio 25.1.3.4922), both now parse cleanly (with the pre-existing, unrelated VSTPluginEvent: Unknown marker 12 warning on one of them).
  • A small local corpus of FL Studio 11.1.1 / 12.5.1.5 / 24.2.1.4526 projects.

Disclaimer: AI assisted in writing this fix.

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
icedream marked this pull request as draft September 8, 2026 04:59
@icedream icedream changed the title Fix Python 3.12+ compatibility: EventEnum empty-enum TypeError [Hack] Fix Python 3.12+ compatibility: EventEnum empty-enum TypeError Sep 8, 2026
@icedream icedream changed the title [Hack] Fix Python 3.12+ compatibility: EventEnum empty-enum TypeError fix: restore EventEnum(value) lookup on Python 3.12+ Sep 8, 2026
@icedream
icedream marked this pull request as ready for review September 8, 2026 05:18
@icedream
icedream force-pushed the fix/py312-enum-and-fl2026 branch from 6ca068a to 2354fbf Compare September 8, 2026 05:41
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

Successfully merging this pull request may close these issues.

🐞 Python 3.12 Enum issue

1 participant