mirror of
https://github.com/python/cpython.git
synced 2025-07-09 20:35:26 +00:00
bpo-42500: Fix recursion in or after except (GH-23568) (#24501)
* Use counter, rather boolean state when handling soft overflows.
(cherry picked from commit 4e7a69bdb6
)
This commit is contained in:
parent
f836e5f219
commit
8b795ab554
9 changed files with 76 additions and 75 deletions
|
@ -1160,7 +1160,6 @@ static PyObject *
|
|||
sys_setrecursionlimit_impl(PyObject *module, int new_limit)
|
||||
/*[clinic end generated code: output=35e1c64754800ace input=b0f7a23393924af3]*/
|
||||
{
|
||||
int mark;
|
||||
PyThreadState *tstate = _PyThreadState_GET();
|
||||
|
||||
if (new_limit < 1) {
|
||||
|
@ -1178,8 +1177,7 @@ sys_setrecursionlimit_impl(PyObject *module, int new_limit)
|
|||
Reject too low new limit if the current recursion depth is higher than
|
||||
the new low-water mark. Otherwise it may not be possible anymore to
|
||||
reset the overflowed flag to 0. */
|
||||
mark = _Py_RecursionLimitLowerWaterMark(new_limit);
|
||||
if (tstate->recursion_depth >= mark) {
|
||||
if (tstate->recursion_depth >= new_limit) {
|
||||
_PyErr_Format(tstate, PyExc_RecursionError,
|
||||
"cannot set the recursion limit to %i at "
|
||||
"the recursion depth %i: the limit is too low",
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue