diff Python/errors.c @ 52738:54b2cd21ab46 legacy-trunk

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.
author Georg Brandl <georg@python.org>
date Thu, 02 Apr 2009 18:09:04 +0000
parents 7e86fa255fc2
children d64d47ee54a1
line wrap: on
line diff
--- a/Python/errors.c	Thu Apr 02 17:43:07 2009 +0000
+++ b/Python/errors.c	Thu Apr 02 18:09:04 2009 +0000
@@ -225,7 +225,15 @@
 	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);