Skip to content

Commit

Permalink
Support Python 3.9.2+ (hzdg#121)
Browse files Browse the repository at this point in the history
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`.
  • Loading branch information
shadchin authored Feb 22, 2021
1 parent 2b3cbcc commit 8a54ab6
Showing 1 changed file with 4 additions and 0 deletions.
4 changes: 4 additions & 0 deletions enumfields/enums.py
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
import sys
import inspect
from enum import _EnumDict
from enum import Enum as BaseEnum
Expand All @@ -15,6 +16,9 @@ def __new__(mcs, name, bases, attrs):
if hasattr(attrs, '_member_names'):
attrs._member_names.remove('Labels')

if sys.version_info >= (3, 9, 2):
attrs._cls_name = name

obj = BaseEnumMeta.__new__(mcs, name, bases, attrs)
for m in obj:
try:
Expand Down

0 comments on commit 8a54ab6

Please sign in to comment.