"Fossies" - the Fresh Open Source Software Archive  

Source code changes of the file "Python/sysmodule.c" between
Python-3.9.3.tar.xz and Python-3.9.4.tar.xz

About: Python is an interpreted, interactive, object-oriented programming language. It incorporates modules, exceptions, dynamic typing, very high level dynamic data types, and classes. Newest major release.

sysmodule.c  (Python-3.9.3.tar.xz):sysmodule.c  (Python-3.9.4.tar.xz)
skipping to change at line 1150 skipping to change at line 1150
This limit prevents infinite recursion from causing an overflow of the C This limit prevents infinite recursion from causing an overflow of the C
stack and crashing Python. The highest possible limit is platform- stack and crashing Python. The highest possible limit is platform-
dependent. dependent.
[clinic start generated code]*/ [clinic start generated code]*/
static PyObject * static PyObject *
sys_setrecursionlimit_impl(PyObject *module, int new_limit) sys_setrecursionlimit_impl(PyObject *module, int new_limit)
/*[clinic end generated code: output=35e1c64754800ace input=b0f7a23393924af3]*/ /*[clinic end generated code: output=35e1c64754800ace input=b0f7a23393924af3]*/
{ {
int mark;
PyThreadState *tstate = _PyThreadState_GET(); PyThreadState *tstate = _PyThreadState_GET();
if (new_limit < 1) { if (new_limit < 1) {
_PyErr_SetString(tstate, PyExc_ValueError, _PyErr_SetString(tstate, PyExc_ValueError,
"recursion limit must be greater or equal than 1"); "recursion limit must be greater or equal than 1");
return NULL; return NULL;
} }
/* Issue #25274: When the recursion depth hits the recursion limit in /* Issue #25274: When the recursion depth hits the recursion limit in
_Py_CheckRecursiveCall(), the overflowed flag of the thread state is _Py_CheckRecursiveCall(), the overflowed flag of the thread state is
set to 1 and a RecursionError is raised. The overflowed flag is reset set to 1 and a RecursionError is raised. The overflowed flag is reset
to 0 when the recursion depth goes below the low-water mark: see to 0 when the recursion depth goes below the low-water mark: see
Py_LeaveRecursiveCall(). Py_LeaveRecursiveCall().
Reject too low new limit if the current recursion depth is higher than 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 the new low-water mark. Otherwise it may not be possible anymore to
reset the overflowed flag to 0. */ reset the overflowed flag to 0. */
if (tstate->recursion_depth >= new_limit) { mark = _Py_RecursionLimitLowerWaterMark(new_limit);
if (tstate->recursion_depth >= mark) {
_PyErr_Format(tstate, PyExc_RecursionError, _PyErr_Format(tstate, PyExc_RecursionError,
"cannot set the recursion limit to %i at " "cannot set the recursion limit to %i at "
"the recursion depth %i: the limit is too low", "the recursion depth %i: the limit is too low",
new_limit, tstate->recursion_depth); new_limit, tstate->recursion_depth);
return NULL; return NULL;
} }
Py_SetRecursionLimit(new_limit); Py_SetRecursionLimit(new_limit);
Py_RETURN_NONE; Py_RETURN_NONE;
} }
 End of changes. 2 change blocks. 
1 lines changed or deleted 3 lines changed or added

Home  |  About  |  Features  |  All  |  Newest  |  Dox  |  Diffs  |  RSS Feeds  |  Screenshots  |  Comments  |  Imprint  |  Privacy  |  HTTP(S)