diff options
author | Nikita Sobolev <mail@sobolevn.me> | 2023-06-08 18:40:15 (GMT) |
---|---|---|
committer | GitHub <noreply@github.com> | 2023-06-08 18:40:15 (GMT) |
commit | 4ff5690e591b7d11cf11e34bf61004e2ea58ab3c (patch) | |
tree | c0b1237ddb98d5327b8b64371e498f94f620a0a7 /Doc | |
parent | e822a676f1f3bef6c5413e9b856db481c08ac2a5 (diff) | |
download | cpython-4ff5690e591b7d11cf11e34bf61004e2ea58ab3c.zip cpython-4ff5690e591b7d11cf11e34bf61004e2ea58ab3c.tar.gz cpython-4ff5690e591b7d11cf11e34bf61004e2ea58ab3c.tar.bz2 |
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>
Diffstat (limited to 'Doc')
-rw-r--r-- | Doc/howto/enum.rst | 11 |
1 files changed, 10 insertions, 1 deletions
diff --git a/Doc/howto/enum.rst b/Doc/howto/enum.rst index 68b75c5..4312b4c 100644 --- a/Doc/howto/enum.rst +++ b/Doc/howto/enum.rst @@ -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 |