summaryrefslogtreecommitdiffstats
path: root/Python/sysmodule.c
diff options
context:
space:
mode:
authorMark Shannon <mark@hotpy.org>2020-12-02 13:30:55 (GMT)
committerGitHub <noreply@github.com>2020-12-02 13:30:55 (GMT)
commit4e7a69bdb63a104587759d7784124492dcdd496e (patch)
tree5477c7077970d9100d089286b75ce2ff408ac613 /Python/sysmodule.c
parent93a0ef76473683aa3ad215e11df18f7839488c4e (diff)
downloadcpython-4e7a69bdb63a104587759d7784124492dcdd496e.zip
cpython-4e7a69bdb63a104587759d7784124492dcdd496e.tar.gz
cpython-4e7a69bdb63a104587759d7784124492dcdd496e.tar.bz2
bpo-42500: Fix recursion in or after except (GH-23568)
* Use counter, rather boolean state when handling soft overflows.
Diffstat (limited to 'Python/sysmodule.c')
-rw-r--r--Python/sysmodule.c4
1 files changed, 1 insertions, 3 deletions
diff --git a/Python/sysmodule.c b/Python/sysmodule.c
index f05b33a..b80d37d 100644
--- a/Python/sysmodule.c
+++ b/Python/sysmodule.c
@@ -1181,7 +1181,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) {
@@ -1199,8 +1198,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",