Repository navigation
3.12.0b4 enum.IntFlag NoneType object is not iterable #106928
Description
Activity
- addedtype-bugAn unexpected behavior, bug, or errorAn unexpected behavior, bug, or error
on 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.
Reacted by Kirill Podoprigora- addedstdlibStandard Library Python modules in the Lib/ directoryStandard Library Python modules in the Lib/ directory3.12only security fixesonly security fixes3.13only security fixesonly security fixes
on Jul 20, 2023 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, butbitmap.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.
Please open an issue with zigpy and reference this one. They should be able to confirm if this is a problem in practice.
Reacted by Marc MuellerWhile 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):
import enum class AlwaysCreateEnumType(enum.EnumMeta): """Enum metaclass that skips the functional creation API.""" def __call__(cls, value, names=None, *values) -> type[enum.Enum]: # type: ignore return cls.__new__(cls, value) # type: ignore class bitmap8( int, enum.ReprEnum, enum.Flag, boundary=enum.KEEP, metaclass=AlwaysCreateEnumType, ): pass bitmap8(0) # works with 3.11 and 3.12
You can consider this issue resolved if no other projects rely on using the
enumclasses this way.
Metadata
Metadata
Assignees
Labels
Projects
- StatusShow more project fieldsDone
Bug report
3.11
3.12.0b4
I bisected the issue to #99500.
/CC: @ethanfurman
Your environment
3.12.0b4