[Python-bugs-list] [ python-Bugs-420343 ] SystemError from tuple() builtin
noreply@sourceforge.net
noreply@sourceforge.net
Mon, 28 May 2001 06:18:09 -0700
Bugs item #420343, was updated on 2001-04-30 19:18
You can respond by visiting:
http://sourceforge.net/tracker/?func=detail&atid=105470&aid=420343&group_id=5470
Category: Python Interpreter Core
Group: None
Status: Open
Resolution: None
Priority: 6
Submitted By: Greg Chapman (glchapman)
>Assigned to: Moshe Zadka (moshez)
Summary: SystemError from tuple() builtin
Initial Comment:
The following produces a SystemError under Python 2.1:
>>> class Test:
... def __init__(self):
... self.list = [1]
... def __len__(self):
... return 0
... def __getitem__(self, index):
... return self.list[index]
...
>>> t = Test()
>>> tuple(t)
Traceback (most recent call last):
File "<interactive input>", line 1, in ?
SystemError: C:\USERS\greg\PROG\CPP\PYTHON\Python-2.1
\Objects\tupleobject.c:506: bad argument to internal
function
The problem is the call made by PySequence_Tuple to
_PyTuple_Resize. The above code results in an attempt
to resize the empty tuple, the ref count of which is
greater than 1.
----------------------------------------------------------------------
>Comment By: Thomas Wouters (twouters)
Date: 2001-05-28 06:18
Message:
Logged In: YES
user_id=34209
There, fixed for 2.1.1 and 2.2. (revisions 2.50 and
2.48.4.1)
Moshe'll have to decide whether he wants the fix for 2.0.1
(there is no big reason not to, but I don't know where he is
with 2.0.1, so I don't want to check it in without his
okay.) Bug reassigned to Moshe for that purpose.
----------------------------------------------------------------------
Comment By: Thomas Wouters (twouters)
Date: 2001-05-28 04:34
Message:
Logged In: YES
user_id=34209
Hey, howlong has this bug been sitting here ?? Must be
something wrong with SF's bug mail stuff, because even
though this bug is assigned to me, I haven't seen it before
:P Anyway, fixing this, both for 2.2 and 2.1.1.
----------------------------------------------------------------------
Comment By: Tim Peters (tim_one)
Date: 2001-05-07 22:01
Message:
Logged In: YES
user_id=31435
Greg, list(f.xreadlines()) happens to work already under
current CVS Python. But note for the future that attaching
a feature request to an unrelated bug report is a low-
probability way to get anyone to notice ...
----------------------------------------------------------------------
Comment By: Greg Chapman (glchapman)
Date: 2001-04-30 19:41
Message:
Logged In: YES
user_id=86307
Apropos this report and the recent python-dev
thread "Iterators, map, xreadlines and docs":
>>> f = open(r"c:\autoexec.bat")
>>> l = list(f.xreadlines())
Traceback (most recent call last):
File "<interactive input>", line 1, in ?
TypeError: len() of unsized object
Admittedly, using xreadlines like this is silly, but it
probably ought to work. Both PySequence_Tuple and
PySequence_List require len() (PySequence_Size) to succeed,
even though they then pretty much ignore the returned
length. Perhaps they should be changed to be consistent
with the changes in map.
----------------------------------------------------------------------
You can respond by visiting:
http://sourceforge.net/tracker/?func=detail&atid=105470&aid=420343&group_id=5470