Skip to content

Commit

Permalink
Refs #32074 -- Fixed TextChoices/IntegerChoices crash on Python 3.10.
Browse files Browse the repository at this point in the history
EnumMeta has a new keyword argument 'boundary' in Python 3.10. This
is a new mechanism that controls how out-of-range / invalid bits are
handled, see https://bugs.python.org/issue38250.
  • Loading branch information
felixxm authored and carltongibson committed Feb 4, 2021
1 parent aa29c57 commit 5d9b065
Showing 1 changed file with 2 additions and 2 deletions.
4 changes: 2 additions & 2 deletions django/db/models/enums.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
class ChoicesMeta(enum.EnumMeta):
"""A metaclass for creating a enum choices."""

def __new__(metacls, classname, bases, classdict):
def __new__(metacls, classname, bases, classdict, **kwds):
labels = []
for key in classdict._member_names:
value = classdict[key]
Expand All @@ -25,7 +25,7 @@ def __new__(metacls, classname, bases, classdict):
# Use dict.__setitem__() to suppress defenses against double
# assignment in enum's classdict.
dict.__setitem__(classdict, key, value)
cls = super().__new__(metacls, classname, bases, classdict)
cls = super().__new__(metacls, classname, bases, classdict, **kwds)
cls._value2label_map_ = dict(zip(cls._value2member_map_, labels))
# Add a label property to instances of enum which uses the enum member
# that is passed in as "self" as the value to use when looking up the
Expand Down

0 comments on commit 5d9b065

Please sign in to comment.