Skip to content

Commit 54b5e4d

Browse files
gh-91362: reword pickle docs to account for nested classes (GH-92429)
Fixes GH-91362 (cherry picked from commit f9d6c59) Co-authored-by: Shantanu <[email protected]>
1 parent 3c2a1e7 commit 54b5e4d

File tree

1 file changed

+6
-6
lines changed

1 file changed

+6
-6
lines changed

Doc/library/pickle.rst

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -502,10 +502,10 @@ The following types can be pickled:
502502

503503
* tuples, lists, sets, and dictionaries containing only picklable objects;
504504

505-
* functions (built-in and user-defined) defined at the top level of a module
506-
(using :keyword:`def`, not :keyword:`lambda`);
505+
* functions (built-in and user-defined) accessible from the top level of a
506+
module (using :keyword:`def`, not :keyword:`lambda`);
507507

508-
* classes defined at the top level of a module;
508+
* classes accessible from the top level of a module;
509509

510510
* instances of such classes whose :attr:`~object.__dict__` or the result of
511511
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
518518
raised in this case. You can carefully raise this limit with
519519
:func:`sys.setrecursionlimit`.
520520

521-
Note that functions (built-in and user-defined) are pickled by fully qualified
522-
name, not by value. [#]_ This means that only the function name is
523-
pickled, along with the name of the module the function is defined in. Neither
521+
Note that functions (built-in and user-defined) are pickled by fully
522+
:term:`qualified name`, not by value. [#]_ This means that only the function name is
523+
pickled, along with the name of the containing module and classes. Neither
524524
the function's code, nor any of its function attributes are pickled. Thus the
525525
defining module must be importable in the unpickling environment, and the module
526526
must contain the named object, otherwise an exception will be raised. [#]_

0 commit comments

Comments
 (0)