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

SystemError when __len__ returns a non-number #49387

Closed
rhettinger opened this issue Feb 3, 2009 · 8 comments
Closed

SystemError when __len__ returns a non-number #49387

rhettinger opened this issue Feb 3, 2009 · 8 comments
Assignees
Labels
release-blocker type-crash A hard crash of the interpreter, possibly with a core dump

Comments

@rhettinger
Copy link
Contributor

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

    @rhettinger
    Copy link
    Contributor Author

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

    @rhettinger rhettinger added release-blocker type-crash A hard crash of the interpreter, possibly with a core dump labels Feb 3, 2009
    @benjaminp
    Copy link
    Contributor

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

    @pitrou
    Copy link
    Member

    pitrou commented Feb 8, 2009

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

    @benjaminp
    Copy link
    Contributor

    Yes, good idea.

    @pitrou
    Copy link
    Member

    pitrou commented Feb 8, 2009

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

    @pitrou
    Copy link
    Member

    pitrou commented Feb 8, 2009

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

    @benjaminp
    Copy link
    Contributor

    Thanks for the reviews! Fixed in r69451.

    @hagen
    Copy link
    Mannequin

    hagen mannequin commented Feb 10, 2009

    This also solves bpo-3729.

    @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
    release-blocker type-crash A hard crash of the interpreter, possibly with a core dump
    Projects
    None yet
    Development

    No branches or pull requests

    3 participants