Issue #5392: when a very low recursion limit was set, the interpreter would
abort with a fatal error after the recursion limit was hit twice.
diff --git a/Include/ceval.h b/Include/ceval.h
index 919c494..7bd8179 100644
--- a/Include/ceval.h
+++ b/Include/ceval.h
@@ -92,11 +92,10 @@
 #  define _Py_MakeRecCheck(x)  (++(x) > _Py_CheckRecursionLimit)
 #endif
 
-#ifdef USE_STACKCHECK
-#  define _Py_MakeEndRecCheck(x)  (--(x) < _Py_CheckRecursionLimit - 50)
-#else
-#  define _Py_MakeEndRecCheck(x)  (--(x) < _Py_CheckRecursionLimit - 50)
-#endif
+#define _Py_MakeEndRecCheck(x) \
+	(--(x) < ((_Py_CheckRecursionLimit > 100) \
+		? (_Py_CheckRecursionLimit - 50) \
+		: (3 * (_Py_CheckRecursionLimit >> 2))))
 
 #define Py_ALLOW_RECURSION \
   do { unsigned char _old = PyThreadState_GET()->recursion_critical;\