- PyEval_GetFrame() is now declared to return a PyFrameObject *

instead of a plain PyObject *.  (SF patch #686601 by Ben Laurie.)
This commit is contained in:
Guido van Rossum 2003-02-19 15:53:17 +00:00
parent 162e38c6a3
commit 6297a7a9fb
6 changed files with 19 additions and 12 deletions

View file

@ -25,11 +25,13 @@ PyAPI_FUNC(PyObject *) PyEval_CallMethod(PyObject *obj,
PyAPI_FUNC(void) PyEval_SetProfile(Py_tracefunc, PyObject *); PyAPI_FUNC(void) PyEval_SetProfile(Py_tracefunc, PyObject *);
PyAPI_FUNC(void) PyEval_SetTrace(Py_tracefunc, PyObject *); PyAPI_FUNC(void) PyEval_SetTrace(Py_tracefunc, PyObject *);
struct _frame; /* Avoid including frameobject.h */
PyAPI_FUNC(PyObject *) PyEval_GetBuiltins(void); PyAPI_FUNC(PyObject *) PyEval_GetBuiltins(void);
PyAPI_FUNC(PyObject *) PyEval_GetGlobals(void); PyAPI_FUNC(PyObject *) PyEval_GetGlobals(void);
PyAPI_FUNC(PyObject *) PyEval_GetLocals(void); PyAPI_FUNC(PyObject *) PyEval_GetLocals(void);
PyAPI_FUNC(PyObject *) PyEval_GetOwner(void); PyAPI_FUNC(PyObject *) PyEval_GetOwner(void);
PyAPI_FUNC(PyObject *) PyEval_GetFrame(void); PyAPI_FUNC(struct _frame *) PyEval_GetFrame(void);
PyAPI_FUNC(int) PyEval_GetRestricted(void); PyAPI_FUNC(int) PyEval_GetRestricted(void);
/* Look at the current frame's (if any) code's co_flags, and turn on /* Look at the current frame's (if any) code's co_flags, and turn on

View file

@ -107,8 +107,10 @@ PyAPI_FUNC(PyInterpreterState *) PyInterpreterState_Next(PyInterpreterState *);
PyAPI_FUNC(PyThreadState *) PyInterpreterState_ThreadHead(PyInterpreterState *); PyAPI_FUNC(PyThreadState *) PyInterpreterState_ThreadHead(PyInterpreterState *);
PyAPI_FUNC(PyThreadState *) PyThreadState_Next(PyThreadState *); PyAPI_FUNC(PyThreadState *) PyThreadState_Next(PyThreadState *);
typedef struct _frame *(*PyThreadFrameGetter)(PyThreadState *self_);
/* hook for PyEval_GetFrame(), requested for Psyco */ /* hook for PyEval_GetFrame(), requested for Psyco */
PyAPI_DATA(unaryfunc) _PyThreadState_GetFrame; PyAPI_DATA(PyThreadFrameGetter) _PyThreadState_GetFrame;
#ifdef __cplusplus #ifdef __cplusplus
} }

View file

@ -326,6 +326,9 @@ Build
C API C API
----- -----
- PyEval_GetFrame() is now declared to return a PyFrameObject *
instead of a plain PyObject *. (SF patch #686601.)
- PyNumber_Check() now checks that the object has a nb_int or nb_float - PyNumber_Check() now checks that the object has a nb_int or nb_float
slot, rather than simply checking whether it has a non-NULL slot, rather than simply checking whether it has a non-NULL
tp_as_number pointer. tp_as_number pointer.

View file

@ -766,7 +766,7 @@ PyErr_CheckSignals(void)
if (PyThread_get_thread_ident() != main_thread) if (PyThread_get_thread_ident() != main_thread)
return 0; return 0;
#endif #endif
if (!(f = PyEval_GetFrame())) if (!(f = (PyObject *)PyEval_GetFrame()))
f = Py_None; f = Py_None;
for (i = 1; i < NSIG; i++) { for (i = 1; i < NSIG; i++) {

View file

@ -3077,7 +3077,7 @@ PyEval_SetTrace(Py_tracefunc func, PyObject *arg)
PyObject * PyObject *
PyEval_GetBuiltins(void) PyEval_GetBuiltins(void)
{ {
PyFrameObject *current_frame = (PyFrameObject *)PyEval_GetFrame(); PyFrameObject *current_frame = PyEval_GetFrame();
if (current_frame == NULL) if (current_frame == NULL)
return PyThreadState_Get()->interp->builtins; return PyThreadState_Get()->interp->builtins;
else else
@ -3087,7 +3087,7 @@ PyEval_GetBuiltins(void)
PyObject * PyObject *
PyEval_GetLocals(void) PyEval_GetLocals(void)
{ {
PyFrameObject *current_frame = (PyFrameObject *)PyEval_GetFrame(); PyFrameObject *current_frame = PyEval_GetFrame();
if (current_frame == NULL) if (current_frame == NULL)
return NULL; return NULL;
PyFrame_FastToLocals(current_frame); PyFrame_FastToLocals(current_frame);
@ -3097,31 +3097,31 @@ PyEval_GetLocals(void)
PyObject * PyObject *
PyEval_GetGlobals(void) PyEval_GetGlobals(void)
{ {
PyFrameObject *current_frame = (PyFrameObject *)PyEval_GetFrame(); PyFrameObject *current_frame = PyEval_GetFrame();
if (current_frame == NULL) if (current_frame == NULL)
return NULL; return NULL;
else else
return current_frame->f_globals; return current_frame->f_globals;
} }
PyObject * PyFrameObject *
PyEval_GetFrame(void) PyEval_GetFrame(void)
{ {
PyThreadState *tstate = PyThreadState_Get(); PyThreadState *tstate = PyThreadState_Get();
return _PyThreadState_GetFrame((PyObject *)tstate); return _PyThreadState_GetFrame(tstate);
} }
int int
PyEval_GetRestricted(void) PyEval_GetRestricted(void)
{ {
PyFrameObject *current_frame = (PyFrameObject *)PyEval_GetFrame(); PyFrameObject *current_frame = PyEval_GetFrame();
return current_frame == NULL ? 0 : current_frame->f_restricted; return current_frame == NULL ? 0 : current_frame->f_restricted;
} }
int int
PyEval_MergeCompilerFlags(PyCompilerFlags *cf) PyEval_MergeCompilerFlags(PyCompilerFlags *cf)
{ {
PyFrameObject *current_frame = (PyFrameObject *)PyEval_GetFrame(); PyFrameObject *current_frame = PyEval_GetFrame();
int result = cf->cf_flags != 0; int result = cf->cf_flags != 0;
if (current_frame != NULL) { if (current_frame != NULL) {

View file

@ -35,7 +35,7 @@ static PyThread_type_lock head_mutex = NULL; /* Protects interp->tstate_head */
static PyInterpreterState *interp_head = NULL; static PyInterpreterState *interp_head = NULL;
PyThreadState *_PyThreadState_Current = NULL; PyThreadState *_PyThreadState_Current = NULL;
unaryfunc _PyThreadState_GetFrame = NULL; PyThreadFrameGetter _PyThreadState_GetFrame = NULL;
PyInterpreterState * PyInterpreterState *
@ -126,7 +126,7 @@ PyThreadState_New(PyInterpreterState *interp)
{ {
PyThreadState *tstate = PyMem_NEW(PyThreadState, 1); PyThreadState *tstate = PyMem_NEW(PyThreadState, 1);
if (_PyThreadState_GetFrame == NULL) if (_PyThreadState_GetFrame == NULL)
_PyThreadState_GetFrame = (unaryfunc)threadstate_getframe; _PyThreadState_GetFrame = threadstate_getframe;
if (tstate != NULL) { if (tstate != NULL) {
tstate->interp = interp; tstate->interp = interp;