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

An errornous __length_hint__ can make list() raise a SystemError #45894

Closed
avassalotti opened this issue Dec 4, 2007 · 4 comments
Closed

An errornous __length_hint__ can make list() raise a SystemError #45894

avassalotti opened this issue Dec 4, 2007 · 4 comments
Assignees
Labels
type-bug An unexpected behavior, bug, or error

Comments

@avassalotti
Copy link
Member

BPO 1553
Nosy @rhettinger, @tiran, @avassalotti

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/rhettinger'
closed_at = <Date 2007-12-05.12:54:32.701>
created_at = <Date 2007-12-04.05:43:57.401>
labels = ['type-bug']
title = 'An errornous __length_hint__ can make list() raise a SystemError'
updated_at = <Date 2007-12-05.12:54:32.671>
user = 'https://github.com/avassalotti'

bugs.python.org fields:

activity = <Date 2007-12-05.12:54:32.671>
actor = 'christian.heimes'
assignee = 'rhettinger'
closed = True
closed_date = <Date 2007-12-05.12:54:32.701>
closer = 'christian.heimes'
components = []
creation = <Date 2007-12-04.05:43:57.401>
creator = 'alexandre.vassalotti'
dependencies = []
files = []
hgrepos = []
issue_num = 1553
keywords = []
message_count = 4.0
messages = ['58176', '58178', '58208', '58213']
nosy_count = 3.0
nosy_names = ['rhettinger', 'christian.heimes', 'alexandre.vassalotti']
pr_nums = []
priority = 'normal'
resolution = 'fixed'
stage = None
status = 'closed'
superseder = None
type = 'behavior'
url = 'https://bugs.python.org/issue1553'
versions = ['Python 2.6', 'Python 2.5', 'Python 3.0']

@avassalotti
Copy link
Member Author

If an iterator with a __length_hint__ method that returns a negative
integer is passed to list(), a SystemError is raised.

>>> class A:
...     def __iter__(self):
...         return self
...     def __length_hint__(self):
...         return -1
... 
>>> list(A())
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
SystemError: NULL result without error in PyObject_Call

@avassalotti avassalotti added the type-bug An unexpected behavior, bug, or error label Dec 4, 2007
@avassalotti
Copy link
Member Author

Fixed for Py3k in r59316.

Should this gets backported?

@rhettinger
Copy link
Contributor

Please post the patch here. I'll take a look to see if it should be
backported.

@rhettinger rhettinger self-assigned this Dec 5, 2007
@tiran
Copy link
Member

tiran commented Dec 5, 2007

I've backported the fix to 2.5 and trunk. They suffered from the same
problem.

@tiran tiran closed this as completed Dec 5, 2007
@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
type-bug An unexpected behavior, bug, or error
Projects
None yet
Development

No branches or pull requests

3 participants