[New-bugs-announce] [issue45248] Documentation example in copyreg errors

Ciaran Welsh report at bugs.python.org
Mon Sep 20 08:27:27 EDT 2021


New submission from Ciaran Welsh <ciaranwelsh00137 at gmail.com>:

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
```

----------
assignee: docs at python
components: Documentation
messages: 402227
nosy: CiaranWelsh, docs at python
priority: normal
severity: normal
status: open
title: Documentation example in copyreg errors
type: behavior
versions: Python 3.9

_______________________________________
Python tracker <report at bugs.python.org>
<https://bugs.python.org/issue45248>
_______________________________________


More information about the New-bugs-announce mailing list