diff options
author | Christian Heimes <christian@python.org> | 2022-06-16 06:42:36 (GMT) |
---|---|---|
committer | GitHub <noreply@github.com> | 2022-06-16 06:42:36 (GMT) |
commit | 05b32c1c796d6c80479756ae898f488eac5f4f71 (patch) | |
tree | cfeebd93990074a5729b973806c802e047679b46 /Lib/enum.py | |
parent | 8ba1c7f72010dedb80f0794c5f1dd1c97f81ec83 (diff) | |
download | cpython-05b32c1c796d6c80479756ae898f488eac5f4f71.zip cpython-05b32c1c796d6c80479756ae898f488eac5f4f71.tar.gz cpython-05b32c1c796d6c80479756ae898f488eac5f4f71.tar.bz2 |
gh-93820: Fix copy() regression in enum.Flag (GH-93876)
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.
Diffstat (limited to 'Lib/enum.py')
-rw-r--r-- | Lib/enum.py | 3 |
1 files changed, 3 insertions, 0 deletions
diff --git a/Lib/enum.py b/Lib/enum.py index 4261b11..ee32d5d 100644 --- a/Lib/enum.py +++ b/Lib/enum.py @@ -1369,6 +1369,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): |