[issue6477] Pickling of NoneType raises PicklingError
Alexander Belopolsky
report at bugs.python.org
Wed Jun 30 01:19:11 CEST 2010
Alexander Belopolsky <belopolsky at users.sourceforge.net> added the comment:
Ellipsis and NotImplemented are different from None because they are not pickleable themselves. The None situation is more similar to that of say module level functions:
>>> def f(): pass
...
>>> dumps(f) # works
b'\x80\x03c__main__\nf\nq\x00.'
>>> dumps(type(f)) # does not work
Traceback (most recent call last):
..
_pickle.PicklingError: Can't pickle <class 'function'>: attribute lookup builtins.function failed
I think documentation at http://docs.python.org/dev/py3k/library/pickle.html#what-can-be-pickled-and-unpickled
Can be improved in two ways:
1. s/types/objects/ in "The following types can be pickled"
2. Add a note that "type(x) can be pickled" does not follow from "x can be pickled." The object type(x) must itself fall into one on the listed categories.
3. "built-in functions defined at the top level of a module" should probably be "built-in classes or functions defined at the top level of the builtins module"
4. "instances of such classes" should be "instances of picklable classes"
5. "__setstate__() is picklable" should be "output of __getstate__() is picklable"
----------
nosy: +belopolsky
_______________________________________
Python tracker <report at bugs.python.org>
<http://bugs.python.org/issue6477>
_______________________________________
More information about the Python-bugs-list
mailing list