Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Commit e9cfcef

Browse files
committed
Clarify the interpretation of the __getstate__() return value for
new-style classes. Closes SF bug #637941.
1 parent a01fa26 commit e9cfcef

1 file changed

Lines changed: 9 additions & 3 deletions

File tree

Doc/lib/libpickle.tex

Lines changed: 9 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -412,13 +412,19 @@ \subsubsection{Pickling and unpickling normal class
412412
\method{__setstate__()}, it is called with the unpickled
413413
state\footnote{These methods can also be used to implement copying
414414
class instances.}. If there is no \method{__setstate__()} method, the
415-
pickled object must be a dictionary and its items are assigned to the
415+
pickled state must be a dictionary and its items are assigned to the
416416
new instance's dictionary. If a class defines both
417417
\method{__getstate__()} and \method{__setstate__()}, the state object
418418
needn't be a dictionary and these methods can do what they
419-
want\footnote{This protocol is also used by the shallow and deep
419+
want.\footnote{This protocol is also used by the shallow and deep
420420
copying operations defined in the
421-
\refmodule{copy} module.}.
421+
\refmodule{copy} module.}
422+
423+
\begin{notice}[warning]
424+
For new-style classes, if \method{__getstate__()} returns a false
425+
value, the \method{__setstate__()} method will not be called.
426+
\end{notice}
427+
422428

423429
\subsubsection{Pickling and unpickling extension types}
424430

0 commit comments

Comments
 (0)