[Python-Dev] RE: test_sort.py failure (original) (raw)

Armin Rigo arigo at tunes.org
Thu Jul 29 12:07:28 CEST 2004


Hello again,

I will check the following test in when it is fixed:

def test_undetected_mutation(self):
    # Python 2.4a1 did not always detect mutation
    memorywaster = []
    for i in range(20):
        def mutating_cmp(x, y):
            L.append(3)
            L.pop()
            return cmp(x, y)
        L = [1,2]
        self.assertRaises(ValueError, L.sort, mutating_cmp)
        def mutating_cmp(x, y):
            L.append(3)
            del L[:]
            return cmp(x, y)
        self.assertRaises(ValueError, L.sort, mutating_cmp)
        memorywaster = [memorywaster]

In the two parts, the list is emptied using two different ways: L.pop() which uses list_resize(), and del L[:] which uses list_ass_slice(). On my Linux machine, the first test eventually fails on yesterday's CVS head, but the second one passes. Conversely, today's CVS makes the first test pass but the second one fail.

Armin



More information about the Python-Dev mailing list