diff options
-rw-r--r-- | Misc/NEWS | 3 | ||||
-rw-r--r-- | Python/errors.c | 10 |
2 files changed, 12 insertions, 1 deletions
@@ -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 diff --git a/Python/errors.c b/Python/errors.c index 6335388..cccc0f7 100644 --- a/Python/errors.c +++ b/Python/errors.c @@ -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); |