You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
What is your use-case for this behavior? Typically, an enum with no members is meant to be subclassed.
Tbh I stumbled upon this while testing a third party library: https://github.com/zigpy/zigpy
As best as I can tell, they do also subclass it, but bitmap.from_bytes in that case is used in a deserialization routine from a binary struct.
I could post a longer example, just not sure it's all that useful, that's why I condensed it initially.
While this new 3.12 behavior is backwards-incompatible with Python 3.11, we've resolved this problem by avoiding the functional API by replacing the enum metaclass (zigpy/zigpy#1236):
importenumclassAlwaysCreateEnumType(enum.EnumMeta):
"""Enum metaclass that skips the functional creation API."""def__call__(cls, value, names=None, *values) ->type[enum.Enum]: # type: ignorereturncls.__new__(cls, value) # type: ignoreclassbitmap8(
int,
enum.ReprEnum,
enum.Flag,
boundary=enum.KEEP,
metaclass=AlwaysCreateEnumType,
):
passbitmap8(0) # works with 3.11 and 3.12
You can consider this issue resolved if no other projects rely on using the enum classes this way.
Bug report
3.11
3.12.0b4
I bisected the issue to #99500.
/CC: @ethanfurman
Your environment
3.12.0b4
The text was updated successfully, but these errors were encountered: