]> granicus.if.org Git - python/commitdiff
PyErr_NormalizeException may not set an error, so convert the PyErr_SetObject
authorGeorg Brandl <georg@python.org>
Thu, 2 Apr 2009 18:09:04 +0000 (18:09 +0000)
committerGeorg Brandl <georg@python.org>
Thu, 2 Apr 2009 18:09:04 +0000 (18:09 +0000)
call on hitting the recursion limit into just assigning it to the arguments provided.

Misc/NEWS
Python/errors.c

index 196f5a98b20b4c68ed37f9d02a6e28d3079fa633..a331bd77045519dfa9a311ea0fe9f611b1598e5e 100644 (file)
--- a/Misc/NEWS
+++ b/Misc/NEWS
@@ -12,6 +12,9 @@ What's New in Python 2.7 alpha 1
 Core and Builtins
 -----------------
 
+- 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.
 
 - Issue #4865: On MacOSX /Library/Python/2.7/site-packages is added to
index 02e9572173ad1721e1c63b4a757ac64087014cc7..e0ff90f29de10f3b0768cbea40e573ce9174b2dc 100644 (file)
@@ -225,7 +225,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);