summaryrefslogtreecommitdiffstats
path: root/Doc/library/enum.rst
diff options
context:
space:
mode:
authorEthan Furman <ethan@stoneleaf.us>2014-02-08 19:36:27 (GMT)
committerEthan Furman <ethan@stoneleaf.us>2014-02-08 19:36:27 (GMT)
commitca1b794dacc057ce34b20dfa5bbc3afdd8441524 (patch)
treedaae24d6a920592bdb3b8a8538028bb8e5dbabf6 /Doc/library/enum.rst
parent01e46ee7e28f5f14ede2b7078cfd277199751dc3 (diff)
downloadcpython-ca1b794dacc057ce34b20dfa5bbc3afdd8441524.zip
cpython-ca1b794dacc057ce34b20dfa5bbc3afdd8441524.tar.gz
cpython-ca1b794dacc057ce34b20dfa5bbc3afdd8441524.tar.bz2
Close issue20534: all pickle protocols now supported.
Diffstat (limited to 'Doc/library/enum.rst')
-rw-r--r--Doc/library/enum.rst14
1 files changed, 11 insertions, 3 deletions
diff --git a/Doc/library/enum.rst b/Doc/library/enum.rst
index 13f8a3c..7f800e3 100644
--- a/Doc/library/enum.rst
+++ b/Doc/library/enum.rst
@@ -369,10 +369,10 @@ The usual restrictions for pickling apply: picklable enums must be defined in
the top level of a module, since unpickling requires them to be importable
from that module.
-.. warning::
+.. note::
- In order to support the singleton nature of enumeration members, pickle
- protocol version 2 or higher must be used.
+ With pickle protocol version 4 it is possible to easily pickle enums
+ nested in other classes.
Functional API
@@ -420,6 +420,14 @@ The solution is to specify the module name explicitly as follows::
>>> Animals = Enum('Animals', 'ant bee cat dog', module=__name__)
+The new pickle protocol 4 also, in some circumstances, relies on
+:attr:``__qualname__`` being set to the location where pickle will be able
+to find the class. For example, if the class was made available in class
+SomeData in the global scope::
+
+ >>> Animals = Enum('Animals', 'ant bee cat dog', qualname='SomeData.Animals')
+
+
Derived Enumerations
--------------------