diff options
author | Raymond Hettinger <python@rcn.com> | 2003-11-28 21:43:02 (GMT) |
---|---|---|
committer | Raymond Hettinger <python@rcn.com> | 2003-11-28 21:43:02 (GMT) |
commit | 37e136373e0d9ab3bdf25ecd9c42b86281ed21d3 (patch) | |
tree | fc0caf815fcf3da64a1a031065f1ee3f9c3f27c4 /Lib/test | |
parent | b3105911697d57098e9770078d89475f83274344 (diff) | |
download | cpython-37e136373e0d9ab3bdf25ecd9c42b86281ed21d3.zip cpython-37e136373e0d9ab3bdf25ecd9c42b86281ed21d3.tar.gz cpython-37e136373e0d9ab3bdf25ecd9c42b86281ed21d3.tar.bz2 |
Make sure the list.sort's decorate step unwinds itself before returning
an exception raised by the key function.
(Suggested by Michael Hudson.)
Diffstat (limited to 'Lib/test')
-rw-r--r-- | Lib/test/test_sort.py | 7 |
1 files changed, 7 insertions, 0 deletions
diff --git a/Lib/test/test_sort.py b/Lib/test/test_sort.py index 053b338..2659a90 100644 --- a/Lib/test/test_sort.py +++ b/Lib/test/test_sort.py @@ -186,6 +186,13 @@ class TestDecorateSortUndecorate(unittest.TestCase): data = 'The quick Brown fox Jumped over The lazy Dog'.split() self.assertRaises(TypeError, data.sort, "bad", str.lower) + def test_key_with_exception(self): + # Verify that the wrapper has been removed + data = range(-2,2) + dup = data[:] + self.assertRaises(ZeroDivisionError, data.sort, None, lambda x: 1/x) + self.assertEqual(data, dup) + def test_reverse(self): data = range(100) random.shuffle(data) |