diff options
author | Armin Rigo <arigo@tunes.org> | 2006-06-21 21:58:50 +0000 |
---|---|---|
committer | Armin Rigo <arigo@tunes.org> | 2006-06-21 21:58:50 +0000 |
commit | 53c1692f6ac592a8c0d5a6f83017019b52625969 (patch) | |
tree | cf3bbc857dcacec8d9f1ac63c14cb05906fc7378 /Lib/test/test_exceptions.py | |
parent | f92b9c21edd77356179050549465e58276cad532 (diff) | |
download | cpython-git-53c1692f6ac592a8c0d5a6f83017019b52625969.tar.gz |
Fix for an obscure bug introduced by revs 46806 and 46808, with a test.
The problem of checking too eagerly for recursive calls is the
following: if a RuntimeError is caused by recursion, and if code needs
to normalize it immediately (as in the 2nd test), then
PyErr_NormalizeException() needs a call to the RuntimeError class to
instantiate it, and this hits the recursion limit again... causing
PyErr_NormalizeException() to never finish.
Moved this particular recursion check to slot_tp_call(), which is not
involved in instantiating built-in exceptions.
Backport candidate.
Diffstat (limited to 'Lib/test/test_exceptions.py')
-rw-r--r-- | Lib/test/test_exceptions.py | 12 |
1 files changed, 12 insertions, 0 deletions
diff --git a/Lib/test/test_exceptions.py b/Lib/test/test_exceptions.py index 45f5188990..ec8895c747 100644 --- a/Lib/test/test_exceptions.py +++ b/Lib/test/test_exceptions.py @@ -305,6 +305,18 @@ class ExceptionTests(unittest.TestCase): x = DerivedException(fancy_arg=42) self.assertEquals(x.fancy_arg, 42) + def testInfiniteRecursion(self): + def f(): + return f() + self.assertRaises(RuntimeError, f) + + def g(): + try: + return g() + except ValueError: + return -1 + self.assertRaises(RuntimeError, g) + def test_main(): run_unittest(ExceptionTests) |