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
{{ message }}
Repository navigation
3.12.0b4 enum.IntFlag NoneType object is not iterable #106928
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.
Activity
ethanfurman commentedon Jul 20, 2023
Thank you for the report!
What is your use-case for this behavior? Typically, an enum with no members is meant to be subclassed.
cdce8p commentedon Jul 20, 2023
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_bytesin 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.
ethanfurman commentedon Jul 21, 2023
Please open an issue with zigpy and reference this one. They should be able to confirm if this is a problem in practice.
puddly commentedon Jul 26, 2023
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):
You can consider this issue resolved if no other projects rely on using the
enumclasses this way.