Text of bugs.python.org › issue47206 as Styx crawled it on Nov 18, 2026. The page may have changed since. Only its words are kept, without pictures or layout.

Open the live page

Issue 47206: pickle docs are wrong about nested classes - Python tracker

Python Home About News Documentation Downloads Community Foundation Developer's Guide Issue Tracker Issues Search Random Issue Summaries Issues with patch Easy issues Stats User Administration User List Committer List Help Tracker Documentation Tracker Development Report Tracker Problem Issue47206 ➜ This issue tracker has been migrated to GitHub , and is currently read-only . For more information, see the GitHub FAQs in the Python's Developer Guide.

Created on 2022-04-03 15:10 by JelleZijlstra , last changed 2022-04-11 14:59 by admin . Messages (1) msg416625 - (view) Author: Jelle Zijlstra (JelleZijlstra) * Date: 2022-04-03 15:10 https://docs.python.org/3.10/library/pickle.html#what-can-be-pickled-and-unpickled says that only "classes that are defined at the top level of a module" can be pickled. But in fact these work fine in current Python, probably since 3.3 when __qualname__ was added ( https://docs.python.org/3/library/stdtypes.html#definition.__qualname__ ).

Similarly, the docs claim only top-level functions can be pickled, but in fact methods nested in classes work fine. Example script demonstrating that these work: import pickle class X: class Y: pass def method(self): pass print(pickle.dumps(X.Y)) print(pickle.loads(pickle.dumps(X.Y))) print(pickle.dumps(X.Y())) print(pickle.loads(pickle.dumps(X.Y()))) print(pickle.dumps(X.method)) print(pickle.loads(pickle.dumps(X.method))) History Date User Action Args 2022-04-11 14:59:58 admin set github: 91362 2022-04-04 16:30:12 maggyero set nosy: + maggyero 2022-04-03 15:10:59 JelleZijlstra create Supported by The Python Software Foundation , Powered by Roundup Copyright © 1990-2022, Python Software Foundation Legal Statements