Skip to content

SystemError when __len__ returns a non-number #49387

Closed

Description

@rhettinger
BPO 5137
Nosy @rhettinger, @pitrou, @benjaminp
Files
  • crasher_len.py: Example
  • SystemError_bad_len.patch
  • SystemError_bad_len2.patch
  • bad_len3.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 = 'https://github.com/benjaminp'
    closed_at = <Date 2009-02-08.21:07:56.269>
    created_at = <Date 2009-02-03.04:45:14.792>
    labels = ['type-crash', 'release-blocker']
    title = 'SystemError when __len__ returns a non-number'
    updated_at = <Date 2009-02-10.06:55:34.148>
    user = 'https://github.com/rhettinger'

    bugs.python.org fields:

    activity = <Date 2009-02-10.06:55:34.148>
    actor = 'hagen'
    assignee = 'benjamin.peterson'
    closed = True
    closed_date = <Date 2009-02-08.21:07:56.269>
    closer = 'benjamin.peterson'
    components = []
    creation = <Date 2009-02-03.04:45:14.792>
    creator = 'rhettinger'
    dependencies = []
    files = ['12927', '12969', '12979', '12980']
    hgrepos = []
    issue_num = 5137
    keywords = ['patch']
    message_count = 8.0
    messages = ['81024', '81338', '81386', '81393', '81395', '81402', '81418', '81531']
    nosy_count = 4.0
    nosy_names = ['rhettinger', 'pitrou', 'benjamin.peterson', 'hagen']
    pr_nums = []
    priority = 'release blocker'
    resolution = 'fixed'
    stage = None
    status = 'closed'
    superseder = None
    type = 'crash'
    url = 'https://bugs.python.org/issue5137'
    versions = ['Python 3.0', 'Python 3.1']

    Activity

    1. rhettinger commented on Feb 3, 2009

      @rhettinger
      ContributorAuthor

      len(obj) is not happy when obj.__len__() returns a non-number.

    2. benjaminp commented on Feb 7, 2009

      @benjaminp
      Contributor

      Here's patch that raises a TypeError like 2.x.

    3. pitrou commented on Feb 8, 2009

      @pitrou
      Member

      Wouldn't it be better to use PyNumber_AsSsize_t() instead, so as to
      support all __index__-enabled objects?

    4. benjaminp commented on Feb 8, 2009

      @benjaminp
      Contributor

      Yes, good idea.

    5. pitrou commented on Feb 8, 2009

      @pitrou
      Member

      I don't think you need to call PyNumber_Check() (unless you want to
      customize the error message).

    6. pitrou commented on Feb 8, 2009

      @pitrou
      Member

      The patch is ok to me. (I assume all tests pass fine :-))

    7. benjaminp commented on Feb 8, 2009

      @benjaminp
      Contributor

      Thanks for the reviews! Fixed in r69451.

    8. hagen commented on Feb 10, 2009

      hagenmannequin
      Mannequin

      This also solves bpo-3729.

    9. 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

    Labels

    release-blockertype-crashA hard crash of the interpreter, possibly with a core dump

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions