[Python-checkins] gh-91362: reword pickle docs to account for nested classes (GH-92429)

miss-islington webhook-mailer at python.org
Sat May 21 11:11:00 EDT 2022


https://github.com/python/cpython/commit/54b5e4da8a4c6ae527ab238fcd6b9ba0a3ed0fc7
commit: 54b5e4da8a4c6ae527ab238fcd6b9ba0a3ed0fc7
branch: 3.10
author: Miss Islington (bot) <31488909+miss-islington at users.noreply.github.com>
committer: miss-islington <31488909+miss-islington at users.noreply.github.com>
date: 2022-05-21T08:10:56-07:00
summary:

gh-91362: reword pickle docs to account for nested classes (GH-92429)


Fixes GH-91362
(cherry picked from commit f9d6c59917435980fbe1b58c57257c45bfed2244)

Co-authored-by: Shantanu <12621235+hauntsaninja at users.noreply.github.com>

files:
M Doc/library/pickle.rst

diff --git a/Doc/library/pickle.rst b/Doc/library/pickle.rst
index f7db0e8415f4c..920df712ea58f 100644
--- a/Doc/library/pickle.rst
+++ b/Doc/library/pickle.rst
@@ -502,10 +502,10 @@ The following types can be pickled:
 
 * tuples, lists, sets, and dictionaries containing only picklable objects;
 
-* functions (built-in and user-defined) defined at the top level of a module
-  (using :keyword:`def`, not :keyword:`lambda`);
+* functions (built-in and user-defined) accessible from the top level of a
+  module (using :keyword:`def`, not :keyword:`lambda`);
 
-* classes defined at the top level of a module;
+* classes accessible from the top level of a module;
 
 * instances of such classes whose :attr:`~object.__dict__` or the result of
   calling :meth:`__getstate__` is picklable  (see section :ref:`pickle-inst` for
@@ -518,9 +518,9 @@ structure may exceed the maximum recursion depth, a :exc:`RecursionError` will b
 raised in this case.  You can carefully raise this limit with
 :func:`sys.setrecursionlimit`.
 
-Note that functions (built-in and user-defined) are pickled by fully qualified
-name, not by value. [#]_  This means that only the function name is
-pickled, along with the name of the module the function is defined in.  Neither
+Note that functions (built-in and user-defined) are pickled by fully
+:term:`qualified name`, not by value. [#]_  This means that only the function name is
+pickled, along with the name of the containing module and classes.  Neither
 the function's code, nor any of its function attributes are pickled.  Thus the
 defining module must be importable in the unpickling environment, and the module
 must contain the named object, otherwise an exception will be raised. [#]_



More information about the Python-checkins mailing list