[Patches] [ python-Patches-830070 ] itertoolsmodule.c: islice error
messages (827190)
SourceForge.net
noreply at sourceforge.net
Tue Oct 28 02:34:02 EST 2003
Patches item #830070, was opened at 2003-10-25 05:31
Message generated for change (Comment added) made by rhettinger
You can respond by visiting:
https://sourceforge.net/tracker/?func=detail&atid=305470&aid=830070&group_id=5470
Category: None
Group: None
>Status: Closed
>Resolution: Fixed
Priority: 5
Submitted By: Johan M. Hahn (johahn)
Assigned to: Nobody/Anonymous (nobody)
Summary: itertoolsmodule.c: islice error messages (827190)
Initial Comment:
>>> import itertools
>>> itertools.islice('abc', 0)
<itertools.islice object at 0x00A397B0>
>>> itertools.islice('abc', -2)
Traceback (most recent call last):
File "<pyshell#37>", line 1, in -toplevel-
itertools.islice([1,2,3], -2)
ValueError: Indices for islice() must be positive.
Error message is changed to "Indices for islice() must be
non-negative." since 0 is allowed.
>>> itertools.islice('abc', -1)
Traceback (most recent call last):
File "<pyshell#38>", line 1, in -toplevel-
itertools.islice([1,2,3], -1)
ValueError: Stop argument must be an integer or None.
Clearly -1 is an integer. This was due to some
optimization in itertoolsmodule.c. If PyInt_AsLong
returned -1 it was taken as a conversion error. I added
an additional else statement to distinguish the two cases
that change the variable to -2 if it was in fact -1 to
begin with. A little 'hacky' but it seems like the best
soloution and it doesn't undo the optimization.
...johahn
----------------------------------------------------------------------
>Comment By: Raymond Hettinger (rhettinger)
Date: 2003-10-28 02:34
Message:
Logged In: YES
user_id=80475
Fixed the error messages. See Modules/itertoolsmodule.c 1.25
----------------------------------------------------------------------
Comment By: Johan M. Hahn (johahn)
Date: 2003-10-25 05:40
Message:
Logged In: YES
user_id=887415
Let me add that the code has not been compiled. I just
noticed two missing { in the first patch and uploaded a new
version.
----------------------------------------------------------------------
You can respond by visiting:
https://sourceforge.net/tracker/?func=detail&atid=305470&aid=830070&group_id=5470
More information about the Patches
mailing list