diff options
Diffstat (limited to 'Lib/enum.py')
-rw-r--r-- | Lib/enum.py | 16 |
1 files changed, 15 insertions, 1 deletions
diff --git a/Lib/enum.py b/Lib/enum.py index 5bd4da9..e11093c 100644 --- a/Lib/enum.py +++ b/Lib/enum.py @@ -1286,7 +1286,21 @@ class Flag(Enum, boundary=STRICT): """ def __reduce_ex__(self, proto): - return self.__class__, (self._value_, ) + cls = self.__class__ + unknown = self._value_ & ~cls._flag_mask_ + member_value = self._value_ & cls._flag_mask_ + if unknown and member_value: + return _or_, (cls(member_value), unknown) + for val in _iter_bits_lsb(member_value): + rest = member_value & ~val + if rest: + return _or_, (cls(rest), cls._value2member_map_.get(val)) + else: + break + if self._name_ is None: + return cls, (self._value_,) + else: + return getattr, (cls, self._name_) _numeric_repr_ = repr |