Skip to content

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

Closed

Description

@KevinShweh
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']

    Activity

    1. KevinShweh commented on May 17, 2019

      KevinShwehmannequin
      MannequinAuthor

      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.

    2. added
      3.7 (EOL)
      3.8 (EOL)
      interpreter-core
      type-bug
      on May 17, 2019
    3. KevinShweh commented on May 17, 2019

      KevinShwehmannequin
      MannequinAuthor

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

    4. ZackerySpytz commented on May 18, 2019

      ZackerySpytzmannequin
      Mannequin

      I agree that this should be fixed.

    5. benjaminp commented on May 20, 2019

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

    6. miss-islington commented on May 20, 2019

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

    7. miss-islington commented on May 20, 2019

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

    8. transferred this issue fromon Apr 10, 2022
    Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

    Metadata

    Metadata

    Assignees

    No one assigned

      Labels

      3.7 (EOL)3.8 (EOL)interpreter-coretype-bug

      Projects

      No projects

        Milestone

        No milestone

        Relationships

        None yet

        Development

        No branches or pull requests

        Issue actions