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

Default __sizeof__ is wrong for var-sized objects #67817

Closed
pitrou opened this issue Mar 10, 2015 · 6 comments
Closed

Default __sizeof__ is wrong for var-sized objects #67817

pitrou opened this issue Mar 10, 2015 · 6 comments
Labels
interpreter-core (Objects, Python, Grammar, and Parser dirs) type-bug An unexpected behavior, bug, or error

Comments

@pitrou
Copy link
Member

pitrou commented Mar 10, 2015

BPO 23629
Nosy @pitrou, @skrah, @serhiy-storchaka
Files
  • sizeof_var_obj.patch
  • 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 = <Date 2015-03-10.21:41:45.251>
    created_at = <Date 2015-03-10.15:44:19.227>
    labels = ['interpreter-core', 'type-bug']
    title = 'Default __sizeof__ is wrong for var-sized objects'
    updated_at = <Date 2015-03-10.21:41:45.250>
    user = 'https://github.com/pitrou'

    bugs.python.org fields:

    activity = <Date 2015-03-10.21:41:45.250>
    actor = 'pitrou'
    assignee = 'none'
    closed = True
    closed_date = <Date 2015-03-10.21:41:45.251>
    closer = 'pitrou'
    components = ['Interpreter Core']
    creation = <Date 2015-03-10.15:44:19.227>
    creator = 'pitrou'
    dependencies = []
    files = ['38422']
    hgrepos = []
    issue_num = 23629
    keywords = ['patch']
    message_count = 6.0
    messages = ['237776', '237783', '237799', '237811', '237812', '237813']
    nosy_count = 4.0
    nosy_names = ['pitrou', 'skrah', 'python-dev', 'serhiy.storchaka']
    pr_nums = []
    priority = 'normal'
    resolution = 'fixed'
    stage = 'resolved'
    status = 'closed'
    superseder = None
    type = 'behavior'
    url = 'https://bugs.python.org/issue23629'
    versions = ['Python 2.7', 'Python 3.4', 'Python 3.5']

    @pitrou
    Copy link
    Member Author

    pitrou commented Mar 10, 2015

    In the stdlib, this only appears with the memoryview object, but third-party types can be affected. Attaching patch.

    @pitrou pitrou added interpreter-core (Objects, Python, Grammar, and Parser dirs) type-bug An unexpected behavior, bug, or error labels Mar 10, 2015
    @serhiy-storchaka
    Copy link
    Member

    Good catch! How it worked before?

    Now we can remove __sizeof__ implementations for tuples and bytes.

    Could you please add sizeof test for PyStructSequence types?

    @serhiy-storchaka
    Copy link
    Member

    Ah, tests for PyStructSequence types already exist (tests for sys.flags and sys.float_info).

    The patch LGTM.

    @python-dev
    Copy link
    Mannequin

    python-dev mannequin commented Mar 10, 2015

    New changeset f9afa4f87570 by Antoine Pitrou in branch '3.4':
    Issue bpo-23629: Fix the default __sizeof__ implementation for variable-sized objects.
    https://hg.python.org/cpython/rev/f9afa4f87570

    New changeset 9994e0172a0c by Antoine Pitrou in branch 'default':
    Issue bpo-23629: Fix the default __sizeof__ implementation for variable-sized objects.
    https://hg.python.org/cpython/rev/9994e0172a0c

    @python-dev
    Copy link
    Mannequin

    python-dev mannequin commented Mar 10, 2015

    New changeset dbd48b22b477 by Antoine Pitrou in branch '2.7':
    Issue bpo-23629: Fix the default __sizeof__ implementation for variable-sized objects.
    https://hg.python.org/cpython/rev/dbd48b22b477

    @pitrou
    Copy link
    Member Author

    pitrou commented Mar 10, 2015

    Good, committed.

    @pitrou pitrou closed this as completed Mar 10, 2015
    @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
    interpreter-core (Objects, Python, Grammar, and Parser dirs) type-bug An unexpected behavior, bug, or error
    Projects
    None yet
    Development

    No branches or pull requests

    2 participants