From: Georg Brandl Date: Thu, 2 Apr 2009 18:09:04 +0000 (+0000) Subject: PyErr_NormalizeException may not set an error, so convert the PyErr_SetObject X-Git-Tag: v2.7a1~1597 X-Git-Url: https://granicus.if.org/sourcecode?a=commitdiff_plain;h=d3f03fa715f9f82ab512a444f8452ac5e5c87d3a;p=python 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. --- diff --git a/Misc/NEWS b/Misc/NEWS index 196f5a98b2..a331bd7704 100644 --- 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 diff --git a/Python/errors.c b/Python/errors.c index 02e9572173..e0ff90f29d 100644 --- a/Python/errors.c +++ b/Python/errors.c @@ -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);