GV

GeezerVison

The World Wide Web, restored to 800 pixels of glory.

Home|About|Gaming cabinet|Archives|How it works|Starter sites

On this site

  • Sign in
  • ActionsCI/CD and automation
  • CodespacesCloud development environments
  • All Features
  • Documentation
  • Training
  • Certifications
  • Build with Copilot
  • Customize Copilot
  • Integrations
  • Trending repos
  • GitHub Sponsors
  • Developer articles
  • Enterprises

This view

  • Original page
  • New address

GeezerVison is showing github.com — Objects referencing private-mangled names do not roundtrip properly under pickling. · Issue #77188 · python/cpython

Objects referencing private-mangled names do not roundtrip properly under pickling. #77188

New issue
Copy link
New issue
Copy link
Closed
Closed
Objects referencing private-mangled names do not roundtrip properly under pickling.#77188
Copy link
Assignees
serhiy-storchaka
Labels
3.15bugs and security fixesbugs and security fixesstdlibStandard Library Python modules in the Lib/ directoryStandard Library Python modules in the Lib/ directorytype-featureA feature request or enhancementA feature request or enhancement

Description

anntzer
mannequin
opened on Mar 6, 2018
Issue body actions
BPO 33007
Nosy @avassalotti, @serhiy-storchaka, @anntzer, @MojoVampire, @ZackerySpytz
PRs
  • gh-77188: Add support for pickling private methods and nested classes #21480
  • 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 = None
    closed_at = None
    created_at = <Date 2018-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 = <Date 2020-07-15.17:51:11.385>
    user = 'https://github.com/anntzer'

    bugs.python.org fields:

    activity = <Date 2020-07-15.17:51:11.385>
    actor = 'serhiy.storchaka'
    assignee = 'none'
    closed = False
    closed_date = None
    closer = None
    components = ['Library (Lib)']
    creation = <Date 2018-03-06.05:36:52.125>
    creator = 'Antony.Lee'
    dependencies = []
    files = []
    hgrepos = []
    issue_num = 33007
    keywords = ['patch']
    message_count = 2.0
    messages = ['313306', '349838']
    nosy_count = 5.0
    nosy_names = ['alexandre.vassalotti', 'serhiy.storchaka', 'Antony.Lee', 'josh.r', 'ZackerySpytz']
    pr_nums = ['21480']
    priority = 'normal'
    resolution = None
    stage = 'patch review'
    status = 'open'
    superseder = None
    type = None
    url = 'https://bugs.python.org/issue33007'
    versions = ['Python 3.8', 'Python 3.9', 'Python 3.10']

    Linked PRs

    • gh-77188: Fix pickle to handle name-mangled private methods correctly #99669
    • gh-77188: Add pickle tests for objects with slots #144116
    • [3.14] gh-77188: Add pickle tests for objects with slots (GH-144116) #144119
    • [3.13] gh-77188: Add pickle tests for objects with slots (GH-144116) #144120
    Reacted by Joey Greco and Prajval-1608

    Activity

    Next
    1. anntzer commented on Mar 6, 2018

      @anntzer
      anntzermannequin
      on Mar 6, 2018
      MannequinAuthor
      More actions

      Consider the following example:

          import pickle
      
          class T:
              def __init__(self):
                  self.attr = self.__foo
      
              def __foo(self):
                  pass
      
          print(pickle.loads(pickle.dumps(T())))

      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.

    2. anntzer
      added
      3.7 (EOL)end of lifeend of life
      stdlibStandard Library Python modules in the Lib/ directoryStandard Library Python modules in the Lib/ directory
      on Mar 6, 2018
    3. MojoVampire commented on Aug 16, 2019

      @MojoVampire
      MojoVampiremannequin
      on Aug 16, 2019
      Mannequin
      More actions

      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.

    4. MojoVampire
      added
      3.8 (EOL)end of lifeend of life
      3.9 (EOL)end of lifeend of life
      on Aug 16, 2019
    5. serhiy-storchaka
      added
      3.10 (EOL)end of lifeend of life
      and removed
      3.7 (EOL)end of lifeend of life
      on Jul 15, 2020
    6. ezio-melotti
      transferred this issue fromon Apr 10, 2022
    7. serhiy-storchaka
      added this to Pickle and copy issues 🥒on May 19, 2022
    8. joeyagreco commented on Jul 8, 2022

      @joeyagreco
      joeyagreco
      on Jul 8, 2022
      More actions

      Having this same issue on Python 3.10. Any updates on this?

    9. nanjekyejoannah commented on Oct 7, 2022

      @nanjekyejoannah
      nanjekyejoannah
      on Oct 7, 2022
      Contributor
      More actions

      @joeyagreco We have a PR if the author fixes, I can merge after some verification.

    10. ZackerySpytz commented on Dec 11, 2022

      @ZackerySpytz
      ZackerySpytz
      on Dec 11, 2022
      Contributor
      More actions

      @nanjekyejoannah I have fixed the PR's merge conflicts.

    11. hugovk
      removed
      3.10 (EOL)end of lifeend of life
      3.9 (EOL)end of lifeend of life
      on Apr 7, 2023
    12. 13 remaining items

    13. serhiy-storchaka
      added
      3.15bugs and security fixesbugs and security fixes
      on Jan 6, 2026
    14. serhiy-storchaka commented on Jan 6, 2026

      @serhiy-storchaka
      serhiy-storchaka
      on Jan 6, 2026
      Member
      More actions

      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.

    15. serhiy-storchaka
      self-assigned this
      on Jan 6, 2026
    16. serhiy-storchaka
      added 2 commits that reference this issue on Jan 21, 2026

      pythongh-77188: Add pickle tests for objects with slots

      dd48ef4

      gh-77188: Add pickle tests for objects with slots (GH-144116)

      cf71e34
    17. miss-islington
      added 2 commits that reference this issue on Jan 21, 2026

      pythongh-77188: Add pickle tests for objects with slots (pythonGH-144116

      83148d5

      pythongh-77188: Add pickle tests for objects with slots (pythonGH-144116

      708e9c9
    18. serhiy-storchaka
      added 2 commits that reference this issue on Jan 21, 2026

      [3.14] gh-77188: Add pickle tests for objects with slots (GH-144116) (G…

      a74709d

      [3.13] gh-77188: Add pickle tests for objects with slots (GH-144116) (G…

      ac9715b
    19. serhiy-storchaka
      closed this as completedon Feb 5, 2026
    20. github-project-automation
      moved this to Done in Pickle and copy issues 🥒on Feb 5, 2026
    21. serhiy-storchaka
      added a commit that references this issue on Feb 5, 2026

      gh-77188: Add support for pickling private methods and nested classes (…

      01a1dd2
    22. thunder-coding
      added 2 commits that reference this issue on Feb 15, 2026

      pythongh-77188: Add pickle tests for objects with slots (pythonGH-144116

      15f4923

      pythongh-77188: Add support for pickling private methods and nested c…

      672ba32
    23. ljfp
      added a commit that references this issue on Apr 25, 2026

      pythongh-77188: Add support for pickling private methods and nested c…

      c321be9
    Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

    Metadata

    Metadata

    Assignees

    • @serhiy-storchaka
      serhiy-storchaka

    Labels

    3.15bugs and security fixesbugs and security fixesstdlibStandard Library Python modules in the Lib/ directoryStandard Library Python modules in the Lib/ directorytype-featureA feature request or enhancementA feature request or enhancement

    Projects

    • Pickle and copy issues 🥒
      Status
      Done
      Show more project fields

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions

    You are visitor 01402503 — GeezerVison does not store the pages you look up.
    Best viewed with Netscape Navigator 4.7 or Internet Explorer 6 at 800×600. No cookies required.