Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Commit 406b3d8

Browse files
committed
Merged revisions 71024,71058 via svnmerge from
svn+ssh://[email protected]/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. ........
1 parent 3f96a87 commit 406b3d8

2 files changed

Lines changed: 12 additions & 1 deletion

File tree

Misc/NEWS

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -47,6 +47,9 @@ Core and Builtins
4747
- Issue #5499: The 'c' code for argument parsing functions now only accepts a
4848
byte, and the 'C' code only accepts a unicode character.
4949

50+
- Fix a problem in PyErr_NormalizeException that leads to "undetected errors"
51+
when hitting the recursion limit under certain circumstances.
52+
5053
- Issue #1665206: Remove the last eager import in _warnings.c and make it lazy.
5154

5255
- Fix a segfault when running test_exceptions with coverage, caused by

Python/errors.c

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -279,7 +279,15 @@ PyErr_NormalizeException(PyObject **exc, PyObject **val, PyObject **tb)
279279
tstate = PyThreadState_GET();
280280
if (++tstate->recursion_depth > Py_GetRecursionLimit()) {
281281
--tstate->recursion_depth;
282-
PyErr_SetObject(PyExc_RuntimeError, PyExc_RecursionErrorInst);
282+
/* throw away the old exception... */
283+
Py_DECREF(*exc);
284+
Py_DECREF(*val);
285+
/* ... and use the recursion error instead */
286+
*exc = PyExc_RuntimeError;
287+
*val = PyExc_RecursionErrorInst;
288+
Py_INCREF(*exc);
289+
Py_INCREF(*val);
290+
/* just keeping the old traceback */
283291
return;
284292
}
285293
PyErr_NormalizeException(exc, val, tb);

0 commit comments

Comments
 (0)