diff options
author | Armin Rigo <arigo@tunes.org> | 2003-10-25 14:33:09 (GMT) |
---|---|---|
committer | Armin Rigo <arigo@tunes.org> | 2003-10-25 14:33:09 (GMT) |
commit | 1d313ab9d187d1a2cd379a61363252278cb2314e (patch) | |
tree | 7b931b6b0e3692369f46565bfccd2a48e3b5b265 | |
parent | 092381a9799ebadba1199eb83e40f880a9bb58ee (diff) | |
download | cpython-1d313ab9d187d1a2cd379a61363252278cb2314e.zip cpython-1d313ab9d187d1a2cd379a61363252278cb2314e.tar.gz cpython-1d313ab9d187d1a2cd379a61363252278cb2314e.tar.bz2 |
oh dear. Wrong manipulation. Committed a version of ceval.c from my
no-cyclic-comparison patch at the same time as errors.c.
Reverting ceval.c to the previous revision.
-rw-r--r-- | Python/ceval.c | 48 |
1 files changed, 20 insertions, 28 deletions
diff --git a/Python/ceval.c b/Python/ceval.c index 59054a6..e6b7424 100644 --- a/Python/ceval.c +++ b/Python/ceval.c @@ -510,29 +510,6 @@ Py_SetRecursionLimit(int new_limit) recursion_limit = new_limit; } -int -_Py_CheckRecursiveCall(char *where) -{ - PyThreadState *tstate = PyThreadState_GET(); - -#ifdef USE_STACKCHECK - if (PyOS_CheckStack()) { - --tstate->recursion_depth; - PyErr_SetString(PyExc_MemoryError, "Stack overflow"); - return -1; - } -#endif - if (tstate->recursion_depth > recursion_limit) { - --tstate->recursion_depth; - PyErr_Format(PyExc_RuntimeError, - "maximum recursion depth exceeded%s", - where); - return -1; - } - return 0; -} - - /* Status code for main loop (reason for stack unwind) */ enum why_code { @@ -697,9 +674,21 @@ eval_frame(PyFrameObject *f) if (f == NULL) return NULL; +#ifdef USE_STACKCHECK + if (tstate->recursion_depth%10 == 0 && PyOS_CheckStack()) { + PyErr_SetString(PyExc_MemoryError, "Stack overflow"); + return NULL; + } +#endif + /* push frame */ - if (Py_EnterRecursiveCall("")) + if (++tstate->recursion_depth > recursion_limit) { + --tstate->recursion_depth; + PyErr_SetString(PyExc_RuntimeError, + "maximum recursion depth exceeded"); + tstate->frame = f->f_back; return NULL; + } tstate->frame = f; @@ -721,7 +710,9 @@ eval_frame(PyFrameObject *f) if (call_trace(tstate->c_tracefunc, tstate->c_traceobj, f, PyTrace_CALL, Py_None)) { /* Trace function raised an error */ - goto exit_eval_frame; + --tstate->recursion_depth; + tstate->frame = f->f_back; + return NULL; } } if (tstate->c_profilefunc != NULL) { @@ -731,7 +722,9 @@ eval_frame(PyFrameObject *f) tstate->c_profileobj, f, PyTrace_CALL, Py_None)) { /* Profile function raised an error */ - goto exit_eval_frame; + --tstate->recursion_depth; + tstate->frame = f->f_back; + return NULL; } } } @@ -2435,8 +2428,7 @@ eval_frame(PyFrameObject *f) reset_exc_info(tstate); /* pop frame */ - exit_eval_frame: - Py_LeaveRecursiveCall(); + --tstate->recursion_depth; tstate->frame = f->f_back; return retval; |