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.

classification
Title: Documentation example in copyreg errors
Type: behavior Stage: resolved
Components: Documentation Versions: Python 3.9
process
Status: closed Resolution:
Dependencies: Superseder:
Assigned To: docs@python Nosy List: CiaranWelsh, docs@python
Priority: normal Keywords:

Created on 2021-09-20 12:27 by CiaranWelsh, last changed 2022-04-11 14:59 by admin. This issue is now closed.

Messages (1)
msg402227 - (view) Author: Ciaran Welsh (CiaranWelsh) Date: 2021-09-20 12:27
The example on https://docs.python.org/3/library/copyreg.html does not work: 

```
        import copyreg, copy, pickle
        class C:
            def __init__(self, a):
                self.a = a
    
        def pickle_c(c):
            print("pickling a C instance...")
            return C, (c.a,)
    
        copyreg.pickle(C, pickle_c)
        c = C(1)
        d = copy.copy(c)
    
>       p = pickle.dumps(c)
E       AttributeError: Can't pickle local object 'RoadRunnerPickleTests.test_ex.<locals>.C'

picklable_swig_tests.py:133: AttributeError
```
History
Date User Action Args
2022-04-11 14:59:50adminsetgithub: 89411
2021-09-20 12:31:52CiaranWelshsetstatus: open -> closed
stage: resolved
2021-09-20 12:27:27CiaranWelshcreate