mirror of
https://github.com/python/cpython.git
synced 2025-09-27 02:39:58 +00:00
gh-105332: [Enum] Fix unpickling flags in edge-cases (GH-105348)
* revert enum pickling from by-name to by-value Co-authored-by: Ethan Furman <ethan@stoneleaf.us>
This commit is contained in:
parent
e822a676f1
commit
4ff5690e59
4 changed files with 47 additions and 23 deletions
|
@ -517,7 +517,16 @@ from that module.
|
|||
nested in other classes.
|
||||
|
||||
It is possible to modify how enum members are pickled/unpickled by defining
|
||||
:meth:`__reduce_ex__` in the enumeration class.
|
||||
:meth:`__reduce_ex__` in the enumeration class. The default method is by-value,
|
||||
but enums with complicated values may want to use by-name::
|
||||
|
||||
>>> class MyEnum(Enum):
|
||||
... __reduce_ex__ = enum.pickle_by_enum_name
|
||||
|
||||
.. note::
|
||||
|
||||
Using by-name for flags is not recommended, as unnamed aliases will
|
||||
not unpickle.
|
||||
|
||||
|
||||
Functional API
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue