Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Commit 3f06469

Browse files
author
Daniel Stutzbach
committed
#11335: Merge from 3.2: Fix memory leak after key function failure in sort
2 parents fc20b0c + eda70b8 commit 3f06469

1 file changed

Lines changed: 6 additions & 0 deletions

File tree

Lib/test/test_sort.py

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -111,6 +111,12 @@ def __repr__(self):
111111
s.sort(key=CmpToKey(lambda a, b: int(random.random() * 3) - 1))
112112
check("an insane function left some permutation", x, s)
113113

114+
if len(x) >= 2:
115+
def bad_key(x):
116+
raise RuntimeError
117+
s = x[:]
118+
self.assertRaises(RuntimeError, s.sort, key=bad_key)
119+
114120
x = [Complains(i) for i in x]
115121
s = x[:]
116122
random.shuffle(s)

0 commit comments

Comments
 (0)