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

Misuse of Py_SIZE in dict.fromkey() #74050

Closed
serhiy-storchaka opened this issue Mar 21, 2017 · 5 comments
Closed

Misuse of Py_SIZE in dict.fromkey() #74050

serhiy-storchaka opened this issue Mar 21, 2017 · 5 comments
Labels
3.7 (EOL) end of life interpreter-core (Objects, Python, Grammar, and Parser dirs) type-bug An unexpected behavior, bug, or error

Comments

@serhiy-storchaka
Copy link
Member

BPO 29864
Nosy @methane, @serhiy-storchaka, @zhangyangyu
PRs
  • bpo-29864: Don't use Py_SIZE for dict object. #747
  • bpo-29864: Don't use Py_SIZE for dict object. (#747) #750
  • 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 2017-03-21.06:53:59.243>
    created_at = <Date 2017-03-21.06:02:12.946>
    labels = ['interpreter-core', 'type-bug', '3.7']
    title = 'Misuse of Py_SIZE in dict.fromkey()'
    updated_at = <Date 2017-03-24.20:09:03.994>
    user = 'https://github.com/serhiy-storchaka'

    bugs.python.org fields:

    activity = <Date 2017-03-24.20:09:03.994>
    actor = 'serhiy.storchaka'
    assignee = 'none'
    closed = True
    closed_date = <Date 2017-03-21.06:53:59.243>
    closer = 'serhiy.storchaka'
    components = ['Interpreter Core']
    creation = <Date 2017-03-21.06:02:12.946>
    creator = 'serhiy.storchaka'
    dependencies = []
    files = []
    hgrepos = []
    issue_num = 29864
    keywords = []
    message_count = 5.0
    messages = ['289915', '289922', '289924', '289925', '290115']
    nosy_count = 3.0
    nosy_names = ['methane', 'serhiy.storchaka', 'xiang.zhang']
    pr_nums = ['747', '750']
    priority = 'normal'
    resolution = 'fixed'
    stage = 'resolved'
    status = 'closed'
    superseder = None
    type = 'behavior'
    url = 'https://bugs.python.org/issue29864'
    versions = ['Python 3.6', 'Python 3.7']

    @serhiy-storchaka
    Copy link
    Member Author

    In dict.fromkeys() implementation when a dict is passed its size is determined by using the Py_SIZE macro. This is not correct since PyDictObject is not a PyVarObject (but see bpo-28988).

    @serhiy-storchaka serhiy-storchaka added 3.7 (EOL) end of life interpreter-core (Objects, Python, Grammar, and Parser dirs) type-bug An unexpected behavior, bug, or error labels Mar 21, 2017
    @zhangyangyu
    Copy link
    Member

    How about 3.6, Serhiy? I see you treat this as a bugfix on the PR.

    @serhiy-storchaka
    Copy link
    Member Author

    Yes, I treat this as a bugfix but I hesitated about backporting it. Py_SIZE works "by accident" and we can't change the layout of PyDictObject structure in maintain branches.

    I have backported the fix to 3.6, but not to other branches since PyDict_GET_SIZE was added in 3.6 and other branches would need modifying the patch.

    @zhangyangyu
    Copy link
    Member

    I think 3.6 is enough.

    @serhiy-storchaka
    Copy link
    Member Author

    New changeset af839fe by Serhiy Storchaka in branch '3.6':
    bpo-29864: Don't use Py_SIZE for dict object. (#747) (#750)
    af839fe

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