Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Commit 6297a7a

Browse files
committed
- PyEval_GetFrame() is now declared to return a PyFrameObject *
instead of a plain PyObject *. (SF patch #686601 by Ben Laurie.)
1 parent 162e38c commit 6297a7a

6 files changed

Lines changed: 19 additions & 12 deletions

File tree

Include/ceval.h

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -25,11 +25,13 @@ PyAPI_FUNC(PyObject *) PyEval_CallMethod(PyObject *obj,
2525
PyAPI_FUNC(void) PyEval_SetProfile(Py_tracefunc, PyObject *);
2626
PyAPI_FUNC(void) PyEval_SetTrace(Py_tracefunc, PyObject *);
2727

28+
struct _frame; /* Avoid including frameobject.h */
29+
2830
PyAPI_FUNC(PyObject *) PyEval_GetBuiltins(void);
2931
PyAPI_FUNC(PyObject *) PyEval_GetGlobals(void);
3032
PyAPI_FUNC(PyObject *) PyEval_GetLocals(void);
3133
PyAPI_FUNC(PyObject *) PyEval_GetOwner(void);
32-
PyAPI_FUNC(PyObject *) PyEval_GetFrame(void);
34+
PyAPI_FUNC(struct _frame *) PyEval_GetFrame(void);
3335
PyAPI_FUNC(int) PyEval_GetRestricted(void);
3436

3537
/* Look at the current frame's (if any) code's co_flags, and turn on

Include/pystate.h

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -107,8 +107,10 @@ PyAPI_FUNC(PyInterpreterState *) PyInterpreterState_Next(PyInterpreterState *);
107107
PyAPI_FUNC(PyThreadState *) PyInterpreterState_ThreadHead(PyInterpreterState *);
108108
PyAPI_FUNC(PyThreadState *) PyThreadState_Next(PyThreadState *);
109109

110+
typedef struct _frame *(*PyThreadFrameGetter)(PyThreadState *self_);
111+
110112
/* hook for PyEval_GetFrame(), requested for Psyco */
111-
PyAPI_DATA(unaryfunc) _PyThreadState_GetFrame;
113+
PyAPI_DATA(PyThreadFrameGetter) _PyThreadState_GetFrame;
112114

113115
#ifdef __cplusplus
114116
}

Misc/NEWS

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -326,6 +326,9 @@ Build
326326
C API
327327
-----
328328

329+
- PyEval_GetFrame() is now declared to return a PyFrameObject *
330+
instead of a plain PyObject *. (SF patch #686601.)
331+
329332
- PyNumber_Check() now checks that the object has a nb_int or nb_float
330333
slot, rather than simply checking whether it has a non-NULL
331334
tp_as_number pointer.

Modules/signalmodule.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -766,7 +766,7 @@ PyErr_CheckSignals(void)
766766
if (PyThread_get_thread_ident() != main_thread)
767767
return 0;
768768
#endif
769-
if (!(f = PyEval_GetFrame()))
769+
if (!(f = (PyObject *)PyEval_GetFrame()))
770770
f = Py_None;
771771

772772
for (i = 1; i < NSIG; i++) {

Python/ceval.c

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -3077,7 +3077,7 @@ PyEval_SetTrace(Py_tracefunc func, PyObject *arg)
30773077
PyObject *
30783078
PyEval_GetBuiltins(void)
30793079
{
3080-
PyFrameObject *current_frame = (PyFrameObject *)PyEval_GetFrame();
3080+
PyFrameObject *current_frame = PyEval_GetFrame();
30813081
if (current_frame == NULL)
30823082
return PyThreadState_Get()->interp->builtins;
30833083
else
@@ -3087,7 +3087,7 @@ PyEval_GetBuiltins(void)
30873087
PyObject *
30883088
PyEval_GetLocals(void)
30893089
{
3090-
PyFrameObject *current_frame = (PyFrameObject *)PyEval_GetFrame();
3090+
PyFrameObject *current_frame = PyEval_GetFrame();
30913091
if (current_frame == NULL)
30923092
return NULL;
30933093
PyFrame_FastToLocals(current_frame);
@@ -3097,31 +3097,31 @@ PyEval_GetLocals(void)
30973097
PyObject *
30983098
PyEval_GetGlobals(void)
30993099
{
3100-
PyFrameObject *current_frame = (PyFrameObject *)PyEval_GetFrame();
3100+
PyFrameObject *current_frame = PyEval_GetFrame();
31013101
if (current_frame == NULL)
31023102
return NULL;
31033103
else
31043104
return current_frame->f_globals;
31053105
}
31063106

3107-
PyObject *
3107+
PyFrameObject *
31083108
PyEval_GetFrame(void)
31093109
{
31103110
PyThreadState *tstate = PyThreadState_Get();
3111-
return _PyThreadState_GetFrame((PyObject *)tstate);
3111+
return _PyThreadState_GetFrame(tstate);
31123112
}
31133113

31143114
int
31153115
PyEval_GetRestricted(void)
31163116
{
3117-
PyFrameObject *current_frame = (PyFrameObject *)PyEval_GetFrame();
3117+
PyFrameObject *current_frame = PyEval_GetFrame();
31183118
return current_frame == NULL ? 0 : current_frame->f_restricted;
31193119
}
31203120

31213121
int
31223122
PyEval_MergeCompilerFlags(PyCompilerFlags *cf)
31233123
{
3124-
PyFrameObject *current_frame = (PyFrameObject *)PyEval_GetFrame();
3124+
PyFrameObject *current_frame = PyEval_GetFrame();
31253125
int result = cf->cf_flags != 0;
31263126

31273127
if (current_frame != NULL) {

Python/pystate.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,7 @@ static PyThread_type_lock head_mutex = NULL; /* Protects interp->tstate_head */
3535
static PyInterpreterState *interp_head = NULL;
3636

3737
PyThreadState *_PyThreadState_Current = NULL;
38-
unaryfunc _PyThreadState_GetFrame = NULL;
38+
PyThreadFrameGetter _PyThreadState_GetFrame = NULL;
3939

4040

4141
PyInterpreterState *
@@ -126,7 +126,7 @@ PyThreadState_New(PyInterpreterState *interp)
126126
{
127127
PyThreadState *tstate = PyMem_NEW(PyThreadState, 1);
128128
if (_PyThreadState_GetFrame == NULL)
129-
_PyThreadState_GetFrame = (unaryfunc)threadstate_getframe;
129+
_PyThreadState_GetFrame = threadstate_getframe;
130130

131131
if (tstate != NULL) {
132132
tstate->interp = interp;

0 commit comments

Comments
 (0)