https://github.com/python/cpython/commit/49bf2d1cbd1ee3022dffed1af50c40b3a66238bb
commit: 49bf2d1cbd1ee3022dffed1af50c40b3a66238bb
branch: 3.14
author: Miss Islington (bot) <[email protected]>
committer: JelleZijlstra <[email protected]>
date: 2026-05-12T02:53:36Z
summary:

[3.14] gh-148669: Clarify `__reduce__()` module lookup behavior (GH-148670) 
(#149704)

gh-148669: Clarify `__reduce__()` module lookup behavior (GH-148670)
(cherry picked from commit 54a5fd4126df74f7b84d1f8a6a36ef79803f66f9)

Co-authored-by: Victorien <[email protected]>

files:
M Doc/library/pickle.rst

diff --git a/Doc/library/pickle.rst b/Doc/library/pickle.rst
index 02b79a9f3a7a47..efae4910ca4358 100644
--- a/Doc/library/pickle.rst
+++ b/Doc/library/pickle.rst
@@ -59,7 +59,7 @@ The :mod:`!pickle` module differs from :mod:`marshal` in 
several significant way
 * :mod:`marshal` cannot be used to serialize user-defined classes and their
   instances.  :mod:`!pickle` can save and restore class instances 
transparently,
   however the class definition must be importable and live in the same module 
as
-  when the object was stored.
+  when the object was pickled.
 
 * The :mod:`marshal` serialization format is not guaranteed to be portable
   across Python versions.  Because its primary job in life is to support
@@ -696,7 +696,10 @@ or both.
    If a string is returned, the string should be interpreted as the name of a
    global variable.  It should be the object's local name relative to its
    module; the pickle module searches the module namespace to determine the
-   object's module.  This behaviour is typically useful for singletons.
+   object's module: for a given ``obj`` to be pickled, the ``__module__``
+   attribute is looked up on ``obj`` directly, which falls back to a lookup
+   on the type of ``obj`` if no ``__module__`` instance attribute is set.
+   This behaviour is typically useful for singletons.
 
    When a tuple is returned, it must be between two and six items long.
    Optional items can either be omitted, or ``None`` can be provided as their

_______________________________________________
Python-checkins mailing list -- [email protected]
To unsubscribe send an email to [email protected]
https://mail.python.org/mailman3//lists/python-checkins.python.org
Member address: [email protected]

Reply via email to