mirror of
https://github.com/python/cpython.git
synced 2025-09-12 03:37:09 +00:00
#11335: Merge from 3.2: Fix memory leak after key function failure in sort
This commit is contained in:
commit
3f064693bb
1 changed files with 6 additions and 0 deletions
|
@ -111,6 +111,12 @@ class TestBase(unittest.TestCase):
|
||||||
s.sort(key=CmpToKey(lambda a, b: int(random.random() * 3) - 1))
|
s.sort(key=CmpToKey(lambda a, b: int(random.random() * 3) - 1))
|
||||||
check("an insane function left some permutation", x, s)
|
check("an insane function left some permutation", x, s)
|
||||||
|
|
||||||
|
if len(x) >= 2:
|
||||||
|
def bad_key(x):
|
||||||
|
raise RuntimeError
|
||||||
|
s = x[:]
|
||||||
|
self.assertRaises(RuntimeError, s.sort, key=bad_key)
|
||||||
|
|
||||||
x = [Complains(i) for i in x]
|
x = [Complains(i) for i in x]
|
||||||
s = x[:]
|
s = x[:]
|
||||||
random.shuffle(s)
|
random.shuffle(s)
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue