Skip to content

Commit 8a54ab6

Browse files
authored
Support Python 3.9.2+ (#121)
Without this, an exception will be thrown `AttributeError: '_EnumDict' object has no attribute '_cls_name'` Refs: python/cpython@aba12b6 This [line](https://github.com/python/cpython/blob/3.9/Lib/enum.py#L97) expects attribute `_cls_name`.
1 parent 2b3cbcc commit 8a54ab6

File tree

1 file changed

+4
-0
lines changed

1 file changed

+4
-0
lines changed

enumfields/enums.py

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
import sys
12
import inspect
23
from enum import _EnumDict
34
from enum import Enum as BaseEnum
@@ -15,6 +16,9 @@ def __new__(mcs, name, bases, attrs):
1516
if hasattr(attrs, '_member_names'):
1617
attrs._member_names.remove('Labels')
1718

19+
if sys.version_info >= (3, 9, 2):
20+
attrs._cls_name = name
21+
1822
obj = BaseEnumMeta.__new__(mcs, name, bases, attrs)
1923
for m in obj:
2024
try:

0 commit comments

Comments
 (0)