summaryrefslogtreecommitdiffstats
path: root/Include
diff options
context:
space:
mode:
authorVictor Stinner <victor.stinner@gmail.com>2015-10-12 22:16:07 (GMT)
committerVictor Stinner <victor.stinner@gmail.com>2015-10-12 22:16:07 (GMT)
commitf7d2471260a5c0e9c957924881dbe6610c9aaf23 (patch)
tree987e4281fbf5f5487ceb6b6b79e1bd1a96394778 /Include
parent397c42b8cca423b61055e1fa1e60c3f480c01df1 (diff)
parent50856d5ae745d1c9f691afbd78572bf073c941cf (diff)
downloadcpython-f7d2471260a5c0e9c957924881dbe6610c9aaf23.zip
cpython-f7d2471260a5c0e9c957924881dbe6610c9aaf23.tar.gz
cpython-f7d2471260a5c0e9c957924881dbe6610c9aaf23.tar.bz2
Merge 3.5 (sys.setrecursionlimit)
Diffstat (limited to 'Include')
-rw-r--r--Include/ceval.h12
1 files changed, 9 insertions, 3 deletions
diff --git a/Include/ceval.h b/Include/ceval.h
index eb1ee43..b5373a9 100644
--- a/Include/ceval.h
+++ b/Include/ceval.h
@@ -94,10 +94,16 @@ PyAPI_DATA(int) _Py_CheckRecursionLimit;
# define _Py_MakeRecCheck(x) (++(x) > _Py_CheckRecursionLimit)
#endif
+/* Compute the "lower-water mark" for a recursion limit. When
+ * Py_LeaveRecursiveCall() is called with a recursion depth below this mark,
+ * the overflowed flag is reset to 0. */
+#define _Py_RecursionLimitLowerWaterMark(limit) \
+ (((limit) > 200) \
+ ? ((limit) - 50) \
+ : (3 * ((limit) >> 2)))
+
#define _Py_MakeEndRecCheck(x) \
- (--(x) < ((_Py_CheckRecursionLimit > 100) \
- ? (_Py_CheckRecursionLimit - 50) \
- : (3 * (_Py_CheckRecursionLimit >> 2))))
+ (--(x) < _Py_RecursionLimitLowerWaterMark(_Py_CheckRecursionLimit))
#define Py_ALLOW_RECURSION \
do { unsigned char _old = PyThreadState_GET()->recursion_critical;\