[ python-Bugs-848856 ] couple of new list.sort bugs

SourceForge.net noreply at sourceforge.net
Tue Nov 25 06:12:33 EST 2003


Bugs item #848856, was opened at 2003-11-25 11:12
Message generated for change (Tracker Item Submitted) made by Item Submitter
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: Open
Resolution: None
Priority: 5
Submitted By: Michael Hudson (mwh)
Assigned to: Raymond Hettinger (rhettinger)
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]


----------------------------------------------------------------------

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