diff options
author | Miss Islington (bot) <31488909+miss-islington@users.noreply.github.com> | 2023-06-09 01:01:51 (GMT) |
---|---|---|
committer | GitHub <noreply@github.com> | 2023-06-09 01:01:51 (GMT) |
commit | 2f4a2d6c1b0c95f6be33a8c778b0212922a50530 (patch) | |
tree | a9f4a13c9b6138e9cf42b1996681c0d8f21dc10e /Doc/howto | |
parent | 68eeab7fdd1afd11bb058df173cab40d9ebe2b06 (diff) | |
download | cpython-2f4a2d6c1b0c95f6be33a8c778b0212922a50530.zip cpython-2f4a2d6c1b0c95f6be33a8c778b0212922a50530.tar.gz cpython-2f4a2d6c1b0c95f6be33a8c778b0212922a50530.tar.bz2 |
[3.12] gh-105332: [Enum] Fix unpickling flags in edge-cases (GH-105348) (GH-105520)
* revert enum pickling from by-name to by-value
(cherry picked from commit 4ff5690e591b7d11cf11e34bf61004e2ea58ab3c)
Co-authored-by: Nikita Sobolev <mail@sobolevn.me>
Co-authored-by: Ethan Furman <ethan@stoneleaf.us>
Diffstat (limited to 'Doc/howto')
-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 |