]> git.ipfire.org Git - thirdparty/Python/cpython.git/commitdiff
Merged revisions 71024,71058 via svnmerge from
authorGeorg Brandl <georg@python.org>
Sat, 11 Apr 2009 21:24:37 +0000 (21:24 +0000)
committerGeorg Brandl <georg@python.org>
Sat, 11 Apr 2009 21:24:37 +0000 (21:24 +0000)
svn+ssh://pythondev@svn.python.org/python/trunk

........
  r71024 | georg.brandl | 2009-04-02 04:47:44 +0200 (Do, 02 Apr 2009) | 4 lines

  In PyErr_GivenExceptionMatches, temporarily bump the recursion
  limit, so that in the most common case PyObject_IsSubclass will
  not raise a recursion error we have to ignore anyway.
........
  r71058 | georg.brandl | 2009-04-02 20:09:04 +0200 (Do, 02 Apr 2009) | 3 lines

  PyErr_NormalizeException may not set an error, so convert the PyErr_SetObject
  call on hitting the recursion limit into just assigning it to the arguments provided.
........

Misc/NEWS
Python/errors.c

index 9b7f13bc20b54178188d89f0529768622b28c34f..a08f320cad063f40c50b84e58e0cd5bd1cd88c99 100644 (file)
--- a/Misc/NEWS
+++ b/Misc/NEWS
@@ -47,6 +47,9 @@ Core and Builtins
 - Issue #5499: The 'c' code for argument parsing functions now only accepts a
   byte, and the 'C' code only accepts a unicode character.
 
+- Fix a problem in PyErr_NormalizeException that leads to "undetected errors"
+  when hitting the recursion limit under certain circumstances.
+
 - Issue #1665206: Remove the last eager import in _warnings.c and make it lazy.
 
 - Fix a segfault when running test_exceptions with coverage, caused by
index 63353881b004143373632f723315fb755ce9043f..cccc0f777835db82df17792bae5dd48d2995fe6c 100644 (file)
@@ -279,7 +279,15 @@ finally:
        tstate = PyThreadState_GET();
        if (++tstate->recursion_depth > Py_GetRecursionLimit()) {
            --tstate->recursion_depth;
-           PyErr_SetObject(PyExc_RuntimeError, PyExc_RecursionErrorInst);
+           /* throw away the old exception... */
+           Py_DECREF(*exc);
+           Py_DECREF(*val);
+           /* ... and use the recursion error instead */
+           *exc = PyExc_RuntimeError;
+           *val = PyExc_RecursionErrorInst;
+           Py_INCREF(*exc);
+           Py_INCREF(*val);
+           /* just keeping the old traceback */
            return;
        }
        PyErr_NormalizeException(exc, val, tb);