Skip to content

Commit 0abb548

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 <furkantahaonder@gmail.com>
1 parent 67ae454 commit 0abb548

2 files changed

Lines changed: 5 additions & 3 deletions

File tree

Doc/library/pickle.rst

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

569569
.. index:: pair: copy; protocol
570570

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)