[Python-checkins] r71240 - python/trunk/Doc/library/pickle.rst
georg.brandl
python-checkins at python.org
Sun Apr 5 16:40:06 CEST 2009
Author: georg.brandl
Date: Sun Apr 5 16:40:06 2009
New Revision: 71240
Log:
#5370: doc update about unpickling objects with custom __getattr__ etc. methods.
Modified:
python/trunk/Doc/library/pickle.rst
Modified: python/trunk/Doc/library/pickle.rst
==============================================================================
--- python/trunk/Doc/library/pickle.rst (original)
+++ python/trunk/Doc/library/pickle.rst Sun Apr 5 16:40:06 2009
@@ -458,6 +458,15 @@
For :term:`new-style class`\es, if :meth:`__getstate__` returns a false
value, the :meth:`__setstate__` method will not be called.
+.. note::
+
+ At unpickling time, some methods like :meth:`__getattr__`,
+ :meth:`__getattribute__`, or :meth:`__setattr__` may be called upon the
+ instance. In case those methods rely on some internal invariant being
+ true, the type should implement either :meth:`__getinitargs__` or
+ :meth:`__getnewargs__` to establish such an invariant; otherwise, neither
+ :meth:`__new__` nor :meth:`__init__` will be called.
+
Pickling and unpickling extension types
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
More information about the Python-checkins
mailing list