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:
Nikita Sobolev 2023-06-08 21:40:15 +03:00 committed by GitHub
parent e822a676f1
commit 4ff5690e59
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
4 changed files with 47 additions and 23 deletions

View file

@ -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