[issue20534] Enum tests fail with pickle protocol 4

Ethan Furman report at bugs.python.org
Sat Feb 8 14:08:43 CET 2014


Ethan Furman added the comment:

Serhiy commented:
-----------------
> Actually they don't pickle due to wrong __module__. After adding
> 
>    NEI.__module__ = NamedInt.__module__ = __name__
> 
> PicklingError no longer raised for enum class.

If you were to look at the `_make_class_unpicklable` function you would see it works by setting __module__ to <unknown>.  So, in fact, it does not pickle precisely because it has the wrong module, and your change undoes what Enum was tryng to do: if an instance cannot be pickled, don't let the class be pickled either.

----------

_______________________________________
Python tracker <report at bugs.python.org>
<http://bugs.python.org/issue20534>
_______________________________________


More information about the Python-bugs-list mailing list