Closed as not planned
Labels
3.12only security fixesonly security fixes3.13only security fixesonly security fixesstdlibStandard Library Python modules in the Lib/ directoryStandard Library Python modules in the Lib/ directorytype-bugAn unexpected behavior, bug, or errorAn unexpected behavior, bug, or error
Description
Bug report
import enum
class bitmap(enum.IntFlag):
pass
print(bitmap.from_bytes(b'\x00', 'little'))3.11
bitmap(0)
3.12.0b4
Traceback (most recent call last):
File "/.../cpython/test.py", line 6, in <module>
print(bitmap.from_bytes(b'\x00', 'little'))
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/.../cpython/Lib/enum.py", line 742, in __call__
return cls._create_(
^^^^^^^^^^^^^
File "/.../cpython/Lib/enum.py", line 870, in _create_
for item in names:
TypeError: 'NoneType' object is not iterableI bisected the issue to #99500.
/CC: @ethanfurman
Your environment
- CPython versions tested on:
3.12.0b4 - Operating system and architecture: macOS ARM64
Metadata
Metadata
Assignees
Labels
3.12only security fixesonly security fixes3.13only security fixesonly security fixesstdlibStandard Library Python modules in the Lib/ directoryStandard Library Python modules in the Lib/ directorytype-bugAn unexpected behavior, bug, or errorAn unexpected behavior, bug, or error
Projects
- StatusShow more project fieldsDone
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.