summaryrefslogtreecommitdiffstats
path: root/Doc/library/enum.rst
diff options
context:
space:
mode:
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
--------------------