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

Skip to content

Commit 8d97e33

Browse files
committed
Patch #966493: Cleanup generator/eval_frame exposure.
1 parent 634893d commit 8d97e33

5 files changed

Lines changed: 13 additions & 18 deletions

File tree

Include/Python.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -99,6 +99,7 @@
9999
#include "sliceobject.h"
100100
#include "cellobject.h"
101101
#include "iterobject.h"
102+
#include "genobject.h"
102103
#include "descrobject.h"
103104
#include "weakrefobject.h"
104105

Include/ceval.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -64,7 +64,7 @@ PyAPI_FUNC(char *) PyEval_GetFuncName(PyObject *);
6464
PyAPI_FUNC(char *) PyEval_GetFuncDesc(PyObject *);
6565

6666
PyAPI_FUNC(PyObject *) PyEval_GetCallStats(PyObject *);
67-
PyAPI_FUNC(PyObject *) PyEval_EvaluateFrame(PyObject *);
67+
PyAPI_FUNC(PyObject *) PyEval_EvalFrame(struct _frame *);
6868

6969
/* this used to be handled on a per-thread basis - now just two globals */
7070
PyAPI_DATA(volatile int) _Py_Ticker;

Include/genobject.h

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -7,11 +7,13 @@
77
extern "C" {
88
#endif
99

10+
struct _frame; /* Avoid including frameobject.h */
11+
1012
typedef struct {
1113
PyObject_HEAD
1214
/* The gi_ prefix is intended to remind of generator-iterator. */
1315

14-
PyFrameObject *gi_frame;
16+
struct _frame *gi_frame;
1517

1618
/* True if generator is being executed. */
1719
int gi_running;
@@ -25,7 +27,7 @@ PyAPI_DATA(PyTypeObject) PyGen_Type;
2527
#define PyGen_Check(op) PyObject_TypeCheck(op, &PyGen_Type)
2628
#define PyGen_CheckExact(op) ((op)->ob_type == &PyGen_Type)
2729

28-
PyAPI_FUNC(PyObject *) PyGen_New(PyFrameObject *);
30+
PyAPI_FUNC(PyObject *) PyGen_New(struct _frame *);
2931

3032
#ifdef __cplusplus
3133
}

Objects/genobject.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -44,7 +44,7 @@ gen_iternext(PyGenObject *gen)
4444
f->f_back = tstate->frame;
4545

4646
gen->gi_running = 1;
47-
result = PyEval_EvaluateFrame((PyObject *)f);
47+
result = PyEval_EvalFrame(f);
4848
gen->gi_running = 0;
4949

5050
/* Don't keep the reference to f_back any longer than necessary. It

Python/ceval.c

Lines changed: 6 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,6 @@
1010

1111
#include "compile.h"
1212
#include "frameobject.h"
13-
#include "genobject.h"
1413
#include "eval.h"
1514
#include "opcode.h"
1615
#include "structmember.h"
@@ -49,7 +48,6 @@ void dump_tsc(int opcode, int ticked, uint64 inst0, uint64 inst1,
4948
typedef PyObject *(*callproc)(PyObject *, PyObject *, PyObject *);
5049

5150
/* Forward declarations */
52-
static PyObject *eval_frame(PyFrameObject *);
5351
#ifdef WITH_TSC
5452
static PyObject *call_function(PyObject ***, int, uint64*, uint64*);
5553
#else
@@ -458,8 +456,8 @@ PyEval_EvalCode(PyCodeObject *co, PyObject *globals, PyObject *locals)
458456

459457
/* Interpreter main loop */
460458

461-
static PyObject *
462-
eval_frame(PyFrameObject *f)
459+
PyObject *
460+
PyEval_EvalFrame(PyFrameObject *f)
463461
{
464462
#ifdef DXPAIRS
465463
int lastopcode = 0;
@@ -2455,8 +2453,8 @@ eval_frame(PyFrameObject *f)
24552453
}
24562454

24572455
/* this is gonna seem *real weird*, but if you put some other code between
2458-
eval_frame() and PyEval_EvalCodeEx() you will need to adjust the test in
2459-
the if statement in Misc/gdbinit:ppystack */
2456+
PyEval_EvalFrame() and PyEval_EvalCodeEx() you will need to adjust
2457+
the test in the if statement in Misc/gdbinit:ppystack */
24602458

24612459
PyObject *
24622460
PyEval_EvalCodeEx(PyCodeObject *co, PyObject *globals, PyObject *locals,
@@ -2684,7 +2682,7 @@ PyEval_EvalCodeEx(PyCodeObject *co, PyObject *globals, PyObject *locals,
26842682
return PyGen_New(f);
26852683
}
26862684

2687-
retval = eval_frame(f);
2685+
retval = PyEval_EvalFrame(f);
26882686

26892687
fail: /* Jump here from prelude on failure */
26902688

@@ -3415,12 +3413,6 @@ PyEval_GetFuncDesc(PyObject *func)
34153413
}
34163414
}
34173415

3418-
PyObject *
3419-
PyEval_EvaluateFrame(PyObject *fo)
3420-
{
3421-
return eval_frame((PyFrameObject *)fo);
3422-
}
3423-
34243416
#define EXT_POP(STACK_POINTER) (*--(STACK_POINTER))
34253417

34263418
static void
@@ -3597,7 +3589,7 @@ fast_function(PyObject *func, PyObject ***pp_stack, int n, int na, int nk)
35973589
Py_INCREF(*stack);
35983590
fastlocals[i] = *stack++;
35993591
}
3600-
retval = eval_frame(f);
3592+
retval = PyEval_EvalFrame(f);
36013593
assert(tstate != NULL);
36023594
++tstate->recursion_depth;
36033595
Py_DECREF(f);

0 commit comments

Comments
 (0)