Made function declaration a proper C prototype

This commit is contained in:
Armin Rigo 2003-10-25 14:29:27 +00:00
parent 8ed69e3389
commit 092381a979
2 changed files with 29 additions and 21 deletions

View file

@ -510,6 +510,29 @@ Py_SetRecursionLimit(int new_limit)
recursion_limit = 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) */ /* Status code for main loop (reason for stack unwind) */
enum why_code { enum why_code {
@ -674,21 +697,9 @@ eval_frame(PyFrameObject *f)
if (f == NULL) if (f == NULL)
return 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 */ /* push frame */
if (++tstate->recursion_depth > recursion_limit) { if (Py_EnterRecursiveCall(""))
--tstate->recursion_depth;
PyErr_SetString(PyExc_RuntimeError,
"maximum recursion depth exceeded");
tstate->frame = f->f_back;
return NULL; return NULL;
}
tstate->frame = f; tstate->frame = f;
@ -710,9 +721,7 @@ eval_frame(PyFrameObject *f)
if (call_trace(tstate->c_tracefunc, tstate->c_traceobj, if (call_trace(tstate->c_tracefunc, tstate->c_traceobj,
f, PyTrace_CALL, Py_None)) { f, PyTrace_CALL, Py_None)) {
/* Trace function raised an error */ /* Trace function raised an error */
--tstate->recursion_depth; goto exit_eval_frame;
tstate->frame = f->f_back;
return NULL;
} }
} }
if (tstate->c_profilefunc != NULL) { if (tstate->c_profilefunc != NULL) {
@ -722,9 +731,7 @@ eval_frame(PyFrameObject *f)
tstate->c_profileobj, tstate->c_profileobj,
f, PyTrace_CALL, Py_None)) { f, PyTrace_CALL, Py_None)) {
/* Profile function raised an error */ /* Profile function raised an error */
--tstate->recursion_depth; goto exit_eval_frame;
tstate->frame = f->f_back;
return NULL;
} }
} }
} }
@ -2428,7 +2435,8 @@ eval_frame(PyFrameObject *f)
reset_exc_info(tstate); reset_exc_info(tstate);
/* pop frame */ /* pop frame */
--tstate->recursion_depth; exit_eval_frame:
Py_LeaveRecursiveCall();
tstate->frame = f->f_back; tstate->frame = f->f_back;
return retval; return retval;

View file

@ -599,7 +599,7 @@ PyErr_WriteUnraisable(PyObject *obj)
Py_XDECREF(tb); Py_XDECREF(tb);
} }
extern PyObject *PyModule_GetWarningsModule(); extern PyObject *PyModule_GetWarningsModule(void);
/* Function to issue a warning message; may raise an exception. */ /* Function to issue a warning message; may raise an exception. */
int int