classification
Title: SystemError when __len__ returns a non-number
Type: crash Stage:
Components: Versions: Python 3.0, Python 3.1
process
Status: closed Resolution: fixed
Dependencies: Superseder:
Assigned To: benjamin.peterson Nosy List: benjamin.peterson, hagen, pitrou, rhettinger
Priority: release blocker Keywords: patch

Created on 2009-02-03 04:45 by rhettinger, last changed 2009-02-10 06:55 by hagen. This issue is now closed.

Files
File name Uploaded Description Edit
crasher_len.py rhettinger, 2009-02-03 04:45 Example
SystemError_bad_len.patch benjamin.peterson, 2009-02-07 16:58
SystemError_bad_len2.patch benjamin.peterson, 2009-02-08 17:34
bad_len3.patch benjamin.peterson, 2009-02-08 17:54
Messages (8)
msg81024 - (view) Author: Raymond Hettinger (rhettinger) * (Python committer) Date: 2009-02-03 04:45
len(obj) is not happy when obj.__len__() returns a non-number.
msg81338 - (view) Author: Benjamin Peterson (benjamin.peterson) * (Python committer) Date: 2009-02-07 16:58
Here's patch that raises a TypeError like 2.x.
msg81386 - (view) Author: Antoine Pitrou (pitrou) * (Python committer) Date: 2009-02-08 16:03
Wouldn't it be better to use PyNumber_AsSsize_t() instead, so as to
support all __index__-enabled objects?
msg81393 - (view) Author: Benjamin Peterson (benjamin.peterson) * (Python committer) Date: 2009-02-08 17:34
Yes, good idea.
msg81395 - (view) Author: Antoine Pitrou (pitrou) * (Python committer) Date: 2009-02-08 17:42
I don't think you need to call PyNumber_Check() (unless you want to
customize the error message).
msg81402 - (view) Author: Antoine Pitrou (pitrou) * (Python committer) Date: 2009-02-08 18:20
The patch is ok to me. (I assume all tests pass fine :-))
msg81418 - (view) Author: Benjamin Peterson (benjamin.peterson) * (Python committer) Date: 2009-02-08 21:07
Thanks for the reviews! Fixed in r69451.
msg81531 - (view) Author: Hagen F├╝rstenau (hagen) Date: 2009-02-10 06:55
This also solves issue 3729.
History
Date User Action Args
2009-02-10 06:55:34hagensetnosy: + hagen
messages: + msg81531
2009-02-08 21:07:56benjamin.petersonsetstatus: open -> closed
resolution: accepted -> fixed
messages: + msg81418
2009-02-08 18:20:44pitrousetkeywords: - needs review
assignee: benjamin.peterson
resolution: accepted
messages: + msg81402
2009-02-08 17:54:10benjamin.petersonsetfiles: + bad_len3.patch
2009-02-08 17:42:16pitrousetmessages: + msg81395
2009-02-08 17:34:09benjamin.petersonsetfiles: + SystemError_bad_len2.patch
messages: + msg81393
2009-02-08 16:03:31pitrousetnosy: + pitrou
messages: + msg81386
2009-02-07 16:58:37benjamin.petersonsetkeywords: + needs review, patch
files: + SystemError_bad_len.patch
messages: + msg81338
nosy: + benjamin.peterson
2009-02-03 04:45:14rhettingercreate