mirror of
https://github.com/python/cpython.git
synced 2025-08-24 18:55:00 +00:00
gh-93820: Fix copy() regression in enum.Flag (GH-93876) (#93886)
GH-26658 introduced a regression in copy / pickle protocol for combined
`enum.Flag`s. `copy.copy(re.A | re.I)` would fail with
`AttributeError: ASCII|IGNORECASE`.
`enum.Flag` now has a `__reduce_ex__()` method that reduces flags by
combined value, not by combined name.
(cherry picked from commit 05b32c1c79
)
Co-authored-by: Christian Heimes <christian@python.org>
Co-authored-by: Christian Heimes <christian@python.org>
This commit is contained in:
parent
74561095d9
commit
3fbf5c6427
3 changed files with 33 additions and 0 deletions
|
@ -1372,6 +1372,9 @@ class Flag(Enum, boundary=STRICT):
|
|||
Support for flags
|
||||
"""
|
||||
|
||||
def __reduce_ex__(self, proto):
|
||||
return self.__class__, (self._value_, )
|
||||
|
||||
_numeric_repr_ = repr
|
||||
|
||||
def _generate_next_value_(name, start, count, last_values):
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue