Skip to content

Commit 020f2aa

Browse files
bpo-27635: Fix pickle documentation about __new__ not being called. (GH-19269)
Automerge-Triggered-By: @pitrou (cherry picked from commit 482259d) Co-authored-by: Furkan Önder <[email protected]>
1 parent bfda4db commit 020f2aa

File tree

2 files changed

+5
-3
lines changed

2 files changed

+5
-3
lines changed

Doc/library/pickle.rst

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -639,9 +639,9 @@ the methods :meth:`__getstate__` and :meth:`__setstate__`.
639639
At unpickling time, some methods like :meth:`__getattr__`,
640640
:meth:`__getattribute__`, or :meth:`__setattr__` may be called upon the
641641
instance. In case those methods rely on some internal invariant being
642-
true, the type should implement :meth:`__getnewargs__` or
643-
:meth:`__getnewargs_ex__` to establish such an invariant; otherwise,
644-
neither :meth:`__new__` nor :meth:`__init__` will be called.
642+
true, the type should implement :meth:`__new__` to establish such an
643+
invariant, as :meth:`__init__` is not called when unpickling an
644+
instance.
645645

646646
.. index:: pair: copy; protocol
647647

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
The pickle documentation incorrectly claimed that ``__new__`` isn't called by
2+
default when unpickling.

0 commit comments

Comments
 (0)