diff options
| author | Mariusz Felisiak <felisiak.mariusz@gmail.com> | 2021-02-03 16:00:04 +0100 |
|---|---|---|
| committer | Carlton Gibson <carlton@noumenal.es> | 2021-02-04 10:47:45 +0100 |
| commit | 5d9b065d3f93de056588dfee6f1776294dd8bab2 (patch) | |
| tree | 59b22329b46c600f09fef9683aa74966de4b15bf | |
| parent | aa29c57beea7e8e570f8a597ea806ca3e2b3431d (diff) | |
Refs #32074 -- Fixed TextChoices/IntegerChoices crash on Python 3.10.
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.
| -rw-r--r-- | django/db/models/enums.py | 4 |
1 files changed, 2 insertions, 2 deletions
diff --git a/django/db/models/enums.py b/django/db/models/enums.py index 51821a2b45..f04698b9f6 100644 --- a/django/db/models/enums.py +++ b/django/db/models/enums.py @@ -8,7 +8,7 @@ __all__ = ['Choices', 'IntegerChoices', 'TextChoices'] 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] @@ -25,7 +25,7 @@ class ChoicesMeta(enum.EnumMeta): # 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 |
