You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
Objects referencing private-mangled names do not roundtrip properly under pickling. #77188
Note: these values reflect the state of the issue at the time it was migrated and might not reflect the current state.
Show more details
GitHub fields:
assignee=Noneclosed_at=Nonecreated_at=<Date2018-03-06.05:36:52.125>labels= ['3.8', 'library', '3.9', '3.10']
title='Objects referencing private-mangled names do not roundtrip properly under pickling.'updated_at=<Date2020-07-15.17:51:11.385>user='https://github.com/anntzer'
This fails on 3.6 with AttributeError: 'T' object has no attribute '__foo' (i.e. there's a lookup on the unmangled name). As a comparison, replacing __foo with _foo results in working code.
This problem is specific to private methods AFAICT, since they're the only things which have an unmangled __name__ used to pickle them, but are stored as a mangled name.
More details on cause and solution on issue bpo-37852, which I closed as a duplicate of this issue.
Activity
anntzer commentedon Mar 6, 2018
Consider the following example:
This fails on 3.6 with
AttributeError: 'T' object has no attribute '__foo'(i.e. there's a lookup on the unmangled name). As a comparison, replacing__foowith_fooresults in working code.MojoVampire commentedon Aug 16, 2019
This problem is specific to private methods AFAICT, since they're the only things which have an unmangled __name__ used to pickle them, but are stored as a mangled name.
More details on cause and solution on issue bpo-37852, which I closed as a duplicate of this issue.
joeyagreco commentedon Jul 8, 2022
Having this same issue on Python 3.10. Any updates on this?
nanjekyejoannah commentedon Oct 7, 2022
@joeyagreco We have a PR if the author fixes, I can merge after some verification.
ZackerySpytz commentedon Dec 11, 2022
@nanjekyejoannah I have fixed the PR's merge conflicts.
13 remaining items
serhiy-storchaka commentedon Jan 6, 2026
Since this never worked before, I reclassify this as a new feature.
#21480 only handles private bound methods. Staticmethods, classmethods and unbound methods are not supported.
pythongh-77188: Add pickle tests for objects with slots
gh-77188: Add pickle tests for objects with slots (GH-144116)
pythongh-77188: Add pickle tests for objects with slots (pythonGH-144116
pythongh-77188: Add pickle tests for objects with slots (pythonGH-144116
[3.14] gh-77188: Add pickle tests for objects with slots (GH-144116) (G…
[3.13] gh-77188: Add pickle tests for objects with slots (GH-144116) (G…
gh-77188: Add support for pickling private methods and nested classes (…
pythongh-77188: Add pickle tests for objects with slots (pythonGH-144116
pythongh-77188: Add support for pickling private methods and nested c…
pythongh-77188: Add support for pickling private methods and nested c…