Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

copyreg does not properly mangle __slots__ names #75290

Closed
ShaneHarvey mannequin opened this issue Aug 2, 2017 · 4 comments
Closed

copyreg does not properly mangle __slots__ names #75290

ShaneHarvey mannequin opened this issue Aug 2, 2017 · 4 comments
Assignees
Labels
3.7 (EOL) end of life stdlib Python modules in the Lib dir type-bug An unexpected behavior, bug, or error

Comments

@ShaneHarvey
Copy link
Mannequin

ShaneHarvey mannequin commented Aug 2, 2017

BPO 31107
Nosy @serhiy-storchaka, @ShaneHarvey
PRs
  • bpo-31107: Fix copyreg mangled slot names calculation. #2989
  • [3.6] bpo-31107: Fix copyreg mangled slot names calculation. (GH-2989) #3003
  • [2.7] bpo-31107: Fix copyreg mangled slot names calculation. (GH-2989). #3004
  • 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 = 'https://github.com/serhiy-storchaka'
    closed_at = <Date 2017-08-05.15:24:03.870>
    created_at = <Date 2017-08-02.18:53:14.769>
    labels = ['3.7', 'type-bug', 'library']
    title = 'copyreg does not properly mangle __slots__ names'
    updated_at = <Date 2017-08-05.15:24:03.861>
    user = 'https://github.com/ShaneHarvey'

    bugs.python.org fields:

    activity = <Date 2017-08-05.15:24:03.861>
    actor = 'serhiy.storchaka'
    assignee = 'serhiy.storchaka'
    closed = True
    closed_date = <Date 2017-08-05.15:24:03.870>
    closer = 'serhiy.storchaka'
    components = ['Library (Lib)']
    creation = <Date 2017-08-02.18:53:14.769>
    creator = 'ShaneHarvey'
    dependencies = []
    files = []
    hgrepos = []
    issue_num = 31107
    keywords = []
    message_count = 4.0
    messages = ['299665', '299737', '299787', '299788']
    nosy_count = 2.0
    nosy_names = ['serhiy.storchaka', 'ShaneHarvey']
    pr_nums = ['2989', '3003', '3004']
    priority = 'normal'
    resolution = 'fixed'
    stage = 'resolved'
    status = 'closed'
    superseder = None
    type = 'behavior'
    url = 'https://bugs.python.org/issue31107'
    versions = ['Python 2.7', 'Python 3.6', 'Python 3.7']

    @ShaneHarvey
    Copy link
    Mannequin Author

    ShaneHarvey mannequin commented Aug 2, 2017

    This line in copyreg._slotnames does not properly calculate mangled attribute names:
    https://github.com/python/cpython/blob/v3.6.2/Lib/copyreg.py#L131

    The problem is that it does not strip leading underscores from the class name:

    >>> class _LeadingUnderscoreClassName(object):
    ...     __slots__ = ("__bar",)
    ...
    >>> import copy_reg
    >>> copy_reg._slotnames(_LeadingUnderscoreClassName)
    ['__LeadingUnderscoreClassName__bar']

    The result is that copy, pickle, and anything else that relies on _slotnames() do not work on classes with leading underscores and private __slots__. This bug is present in all versions of Python.

    @ShaneHarvey ShaneHarvey mannequin added 3.7 (EOL) end of life stdlib Python modules in the Lib dir type-bug An unexpected behavior, bug, or error and removed 3.7 (EOL) end of life labels Aug 2, 2017
    @serhiy-storchaka serhiy-storchaka added the 3.7 (EOL) end of life label Aug 2, 2017
    @serhiy-storchaka serhiy-storchaka self-assigned this Aug 2, 2017
    @serhiy-storchaka
    Copy link
    Member

    New changeset c4c9866 by Serhiy Storchaka (Shane Harvey) in branch 'master':
    bpo-31107: Fix copyreg mangled slot names calculation. (bpo-2989)
    c4c9866

    @serhiy-storchaka
    Copy link
    Member

    New changeset 4795ba8 by Serhiy Storchaka (Shane Harvey) in branch '3.6':
    [3.6] bpo-31107: Fix copyreg mangled slot names calculation. (GH-2989) (bpo-3003)
    4795ba8

    @serhiy-storchaka
    Copy link
    Member

    New changeset 88ffff5 by Serhiy Storchaka (Shane Harvey) in branch '2.7':
    [2.7] bpo-31107: Fix copyreg mangled slot names calculation. (GH-2989). (bpo-3004)
    88ffff5

    @ezio-melotti ezio-melotti transferred this issue from another repository Apr 10, 2022
    Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
    Labels
    3.7 (EOL) end of life stdlib Python modules in the Lib dir type-bug An unexpected behavior, bug, or error
    Projects
    None yet
    Development

    No branches or pull requests

    1 participant