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

Wrong types for PyMemberDefs in Objects/typeobject.c #81132

Closed
KevinShweh mannequin opened this issue May 17, 2019 · 6 comments
Closed

Wrong types for PyMemberDefs in Objects/typeobject.c #81132

KevinShweh mannequin opened this issue May 17, 2019 · 6 comments
Labels
3.7 (EOL) end of life 3.8 (EOL) end of life interpreter-core (Objects, Python, Grammar, and Parser dirs) type-bug An unexpected behavior, bug, or error

Comments

@KevinShweh
Copy link
Mannequin

KevinShweh mannequin commented May 17, 2019

BPO 36951
Nosy @benjaminp, @ZackerySpytz, @miss-islington
PRs
  • bpo-36951: Correct some types in the type_members struct in typeobject.c #13403
  • [3.7] closes bpo-36951: Correct some types in the type_members struct in typeobject.c. (GH-13403) #13433
  • [2.7] closes bpo-36951: Correct some types in the type_members struct in typeobject.c. (GH-13403) #13434
  • 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 2019-05-20.00:26:38.365>
    created_at = <Date 2019-05-17.19:50:54.269>
    labels = ['interpreter-core', '3.8', 'type-bug', '3.7']
    title = 'Wrong types for PyMemberDefs in Objects/typeobject.c'
    updated_at = <Date 2019-05-20.00:54:12.610>
    user = 'https://bugs.python.org/KevinShweh'

    bugs.python.org fields:

    activity = <Date 2019-05-20.00:54:12.610>
    actor = 'miss-islington'
    assignee = 'none'
    closed = True
    closed_date = <Date 2019-05-20.00:26:38.365>
    closer = 'benjamin.peterson'
    components = ['Interpreter Core']
    creation = <Date 2019-05-17.19:50:54.269>
    creator = 'Kevin Shweh'
    dependencies = []
    files = []
    hgrepos = []
    issue_num = 36951
    keywords = ['patch']
    message_count = 6.0
    messages = ['342759', '342760', '342788', '342882', '342883', '342884']
    nosy_count = 4.0
    nosy_names = ['benjamin.peterson', 'Kevin Shweh', 'ZackerySpytz', 'miss-islington']
    pr_nums = ['13403', '13433', '13434']
    priority = 'normal'
    resolution = 'fixed'
    stage = 'resolved'
    status = 'closed'
    superseder = None
    type = 'behavior'
    url = 'https://bugs.python.org/issue36951'
    versions = ['Python 2.7', 'Python 3.7', 'Python 3.8']

    @KevinShweh
    Copy link
    Mannequin Author

    KevinShweh mannequin commented May 17, 2019

    In Objects/typeobject.c, the PyMemberDefs for __flags__, __weakrefoffset__, and __dictoffset__ all use T_LONG:

    {"__flags__", T_LONG, offsetof(PyTypeObject, tp_flags), READONLY},
    {"__weakrefoffset__", T_LONG,
     offsetof(PyTypeObject, tp_weaklistoffset), READONLY},
    ...
    {"__dictoffset__", T_LONG,
     offsetof(PyTypeObject, tp_dictoffset), READONLY},
    
    {"__weakrefoffset__", T_LONG,
     offsetof(PyTypeObject, tp_weaklistoffset), READONLY},
    

    but in Include/object.h or Include/cpython/object.h, the corresponding struct members have types unsigned long, Py_ssize_t, and Py_ssize_t respectively:

        /* Flags to define presence of optional/expanded features */
        unsigned long tp_flags;
        ...
        /* weak reference enabler */
        Py_ssize_t tp_weaklistoffset;
        ...
        Py_ssize_t tp_dictoffset;

    These uses of T_LONG should be changed to T_ULONG and T_PYSSIZE_T.

    This was checked on 3.7.3 and master.

    @KevinShweh KevinShweh mannequin added 3.7 (EOL) end of life 3.8 (EOL) end of life interpreter-core (Objects, Python, Grammar, and Parser dirs) type-bug An unexpected behavior, bug, or error labels May 17, 2019
    @KevinShweh
    Copy link
    Mannequin Author

    KevinShweh mannequin commented May 17, 2019

    Looks like I accidentally doubled the PyMemberDef for __weakrefoffset__ while editing. There's no double definition in the actual file.

    @ZackerySpytz
    Copy link
    Mannequin

    ZackerySpytz mannequin commented May 18, 2019

    I agree that this should be fixed.

    @benjaminp
    Copy link
    Contributor

    New changeset 53d378c by Benjamin Peterson (Zackery Spytz) in branch 'master':
    closes bpo-36951: Correct some types in the type_members struct in typeobject.c. (GH-13403)
    53d378c

    @miss-islington
    Copy link
    Contributor

    New changeset eda691d by Miss Islington (bot) in branch '2.7':
    closes bpo-36951: Correct some types in the type_members struct in typeobject.c. (GH-13403)
    eda691d

    @miss-islington
    Copy link
    Contributor

    New changeset 64b0bdb by Miss Islington (bot) in branch '3.7':
    closes bpo-36951: Correct some types in the type_members struct in typeobject.c. (GH-13403)
    64b0bdb

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