[Python-checkins] cpython (merge 3.2 -> default): #11335: Merge from 3.2: Fix memory leak after key function failure in sort

daniel.stutzbach python-checkins at python.org
Wed May 4 22:06:44 CEST 2011


http://hg.python.org/cpython/rev/18e43c6acfff
changeset:   69837:18e43c6acfff
parent:      69833:c892b0321d23
parent:      69836:52fb7dc721ed
user:        Daniel Stutzbach <daniel.stutzbach at google.com>
date:        Wed May 04 12:47:14 2011 -0700
summary:
  #11335: Merge from 3.2: Fix memory leak after key function failure in sort

files:
  Lib/test/test_sort.py |  6 ++++++
  1 files changed, 6 insertions(+), 0 deletions(-)


diff --git a/Lib/test/test_sort.py b/Lib/test/test_sort.py
--- a/Lib/test/test_sort.py
+++ b/Lib/test/test_sort.py
@@ -111,6 +111,12 @@
             s.sort(key=CmpToKey(lambda a, b:  int(random.random() * 3) - 1))
             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]
             s = x[:]
             random.shuffle(s)

-- 
Repository URL: http://hg.python.org/cpython


More information about the Python-checkins mailing list