[ python-Bugs-848856 ] couple of new list.sort bugs
SourceForge.net
noreply at sourceforge.net
Thu Dec 4 06:26:47 EST 2003
Bugs item #848856, was opened at 2003-11-25 11:12
Message generated for change (Settings changed) made by mwh
You can respond by visiting:
https://sourceforge.net/tracker/?func=detail&atid=105470&aid=848856&group_id=5470
Category: Python Interpreter Core
Group: Python 2.4
>Status: Closed
Resolution: Accepted
Priority: 5
Submitted By: Michael Hudson (mwh)
Assigned to: Michael Hudson (mwh)
Summary: couple of new list.sort bugs
Initial Comment:
I really feel I should apologise for this one:
[mwh at pc150 build-debug]$ cat t.py
class SortKiller(object):
def __init__(self, i):
pass
def __del__(self):
del l[:]
l = range(10)
l.sort(key=SortKiller)
[mwh at pc150 build-debug]$ ./python t.py
Segmentation fault
This can be fixed by moving the "restoring the objects
of the list from the wrappers" code *before* the "put
saved_ob_item back in the list" code.
The second is less serious but probably more annoying
to fix:
[mwh at pc150 build-debug]$ cat u.py
def k(x): return 1/x
l = range(-2,2)
try:
l.sort(key=k)
except ZeroDivisionError:
pass
print l
[mwh at pc150 build-debug]$ ./python u.py
[<sortwrapper object at 0x40130410>, <sortwrapper
object at 0x401303c0>, 0, 1]
[6571 refs]
----------------------------------------------------------------------
>Comment By: Michael Hudson (mwh)
Date: 2003-12-04 11:26
Message:
Logged In: YES
user_id=6656
OK, checked in as:
Objects/listobject.c revision 2.167
Lib/test/test_sort.py revision 1.9
----------------------------------------------------------------------
Comment By: Raymond Hettinger (rhettinger)
Date: 2003-12-04 00:57
Message:
Logged In: YES
user_id=80475
Looks good.
Please add your crashers to the test suite and check it all in.
----------------------------------------------------------------------
Comment By: Michael Hudson (mwh)
Date: 2003-12-02 12:13
Message:
Logged In: YES
user_id=6656
> On the code path leading to a dsu_fail, does
> PyMem_FREE() ever get called?
Good catch. New patch attached.
> Would there be some added protection value to INCREFing self
> at the beginning and DECREFing it at the end?
Um, I don't think so, as the calling machinery holds a
reference to self (and all the other arguments) during the
call. Or did you mean something else?
----------------------------------------------------------------------
Comment By: Raymond Hettinger (rhettinger)
Date: 2003-12-02 06:52
Message:
Logged In: YES
user_id=80475
On the code path leading to a dsu_fail, does PyMem_FREE()
ever get called?
Would there be some added protection value to INCREFing self
at the beginning and DECREFing it at the end?
----------------------------------------------------------------------
Comment By: Michael Hudson (mwh)
Date: 2003-12-01 18:36
Message:
Logged In: YES
user_id=6656
Boy is this stuff hard to get right!
See what you think of the attached patch.
----------------------------------------------------------------------
Comment By: Michael Hudson (mwh)
Date: 2003-12-01 17:38
Message:
Logged In: YES
user_id=6656
Here's a much less devious test case:
$ cat w.py
def k(x):
del l[:]
return x
l = range(10)
l.sort(key=k)
$ ./python w.py
Segmentation fault
i think doing the "hide ob_item" swizzle should be just
about the first thing list_sort does and undoing it should
be about the last. Patch soon (I hope).
----------------------------------------------------------------------
Comment By: Michael Hudson (mwh)
Date: 2003-12-01 12:37
Message:
Logged In: YES
user_id=6656
I have a feeling that your fix for problem #2 has made
problem #1 harder to fix...
will have a look later, no time right now.
----------------------------------------------------------------------
Comment By: Raymond Hettinger (rhettinger)
Date: 2003-11-29 01:56
Message:
Logged In: YES
user_id=80475
The second was easy to fix.
The first is defying my attempts to fix it. You're welcome
to take a crack at it.
----------------------------------------------------------------------
You can respond by visiting:
https://sourceforge.net/tracker/?func=detail&atid=105470&aid=848856&group_id=5470
More information about the Python-bugs-list
mailing list