mirror of
https://github.com/python/cpython.git
synced 2025-07-31 07:04:42 +00:00
bpo-46836: Rename InterpreterFrame to _PyInterpreterFrame (GH-31583)
Rename also struct _interpreter_frame to struct _PyInterpreterFrame. Reduce risk of name conflicts if a project includes pycore_frame.h.
This commit is contained in:
parent
f780d9690f
commit
87af12bff3
15 changed files with 138 additions and 138 deletions
|
@ -629,8 +629,8 @@ frame_dealloc(PyFrameObject *f)
|
|||
/* Kill all local variables including specials, if we own them */
|
||||
if (f->f_owns_frame) {
|
||||
f->f_owns_frame = 0;
|
||||
assert(f->f_frame == (InterpreterFrame *)f->_f_frame_data);
|
||||
InterpreterFrame *frame = (InterpreterFrame *)f->_f_frame_data;
|
||||
assert(f->f_frame == (_PyInterpreterFrame *)f->_f_frame_data);
|
||||
_PyInterpreterFrame *frame = (_PyInterpreterFrame *)f->_f_frame_data;
|
||||
/* Don't clear code object until the end */
|
||||
co = frame->f_code;
|
||||
frame->f_code = NULL;
|
||||
|
@ -707,7 +707,7 @@ static PyObject *
|
|||
frame_sizeof(PyFrameObject *f, PyObject *Py_UNUSED(ignored))
|
||||
{
|
||||
Py_ssize_t res;
|
||||
res = offsetof(PyFrameObject, _f_frame_data) + offsetof(InterpreterFrame, localsplus);
|
||||
res = offsetof(PyFrameObject, _f_frame_data) + offsetof(_PyInterpreterFrame, localsplus);
|
||||
PyCodeObject *code = f->f_frame->f_code;
|
||||
res += (code->co_nlocalsplus+code->co_stacksize) * sizeof(PyObject *);
|
||||
return PyLong_FromSsize_t(res);
|
||||
|
@ -738,7 +738,7 @@ PyTypeObject PyFrame_Type = {
|
|||
PyVarObject_HEAD_INIT(&PyType_Type, 0)
|
||||
"frame",
|
||||
offsetof(PyFrameObject, _f_frame_data) +
|
||||
offsetof(InterpreterFrame, localsplus),
|
||||
offsetof(_PyInterpreterFrame, localsplus),
|
||||
sizeof(PyObject *),
|
||||
(destructor)frame_dealloc, /* tp_dealloc */
|
||||
0, /* tp_vectorcall_offset */
|
||||
|
@ -771,7 +771,7 @@ PyTypeObject PyFrame_Type = {
|
|||
};
|
||||
|
||||
static void
|
||||
init_frame(InterpreterFrame *frame, PyFunctionObject *func, PyObject *locals)
|
||||
init_frame(_PyInterpreterFrame *frame, PyFunctionObject *func, PyObject *locals)
|
||||
{
|
||||
/* _PyFrame_InitializeSpecials consumes reference to func */
|
||||
Py_INCREF(func);
|
||||
|
@ -827,8 +827,8 @@ PyFrame_New(PyThreadState *tstate, PyCodeObject *code,
|
|||
Py_DECREF(func);
|
||||
return NULL;
|
||||
}
|
||||
init_frame((InterpreterFrame *)f->_f_frame_data, func, locals);
|
||||
f->f_frame = (InterpreterFrame *)f->_f_frame_data;
|
||||
init_frame((_PyInterpreterFrame *)f->_f_frame_data, func, locals);
|
||||
f->f_frame = (_PyInterpreterFrame *)f->_f_frame_data;
|
||||
f->f_owns_frame = 1;
|
||||
Py_DECREF(func);
|
||||
_PyObject_GC_TRACK(f);
|
||||
|
@ -836,7 +836,7 @@ PyFrame_New(PyThreadState *tstate, PyCodeObject *code,
|
|||
}
|
||||
|
||||
static int
|
||||
_PyFrame_OpAlreadyRan(InterpreterFrame *frame, int opcode, int oparg)
|
||||
_PyFrame_OpAlreadyRan(_PyInterpreterFrame *frame, int opcode, int oparg)
|
||||
{
|
||||
const _Py_CODEUNIT *code =
|
||||
(const _Py_CODEUNIT *)PyBytes_AS_STRING(frame->f_code->co_code);
|
||||
|
@ -849,7 +849,7 @@ _PyFrame_OpAlreadyRan(InterpreterFrame *frame, int opcode, int oparg)
|
|||
}
|
||||
|
||||
int
|
||||
_PyFrame_FastToLocalsWithError(InterpreterFrame *frame) {
|
||||
_PyFrame_FastToLocalsWithError(_PyInterpreterFrame *frame) {
|
||||
/* Merge fast locals into f->f_locals */
|
||||
PyObject *locals;
|
||||
PyObject **fast;
|
||||
|
@ -960,7 +960,7 @@ PyFrame_FastToLocals(PyFrameObject *f)
|
|||
}
|
||||
|
||||
void
|
||||
_PyFrame_LocalsToFast(InterpreterFrame *frame, int clear)
|
||||
_PyFrame_LocalsToFast(_PyInterpreterFrame *frame, int clear)
|
||||
{
|
||||
/* Merge locals into fast locals */
|
||||
PyObject *locals;
|
||||
|
|
|
@ -7,7 +7,7 @@
|
|||
#include "pycore_object.h" // _PyObject_GC_UNTRACK()
|
||||
#include "pycore_pyerrors.h" // _PyErr_ClearExcState()
|
||||
#include "pycore_pystate.h" // _PyThreadState_GET()
|
||||
#include "pycore_frame.h" // InterpreterFrame
|
||||
#include "pycore_frame.h" // _PyInterpreterFrame
|
||||
#include "frameobject.h" // PyFrameObject
|
||||
#include "structmember.h" // PyMemberDef
|
||||
#include "opcode.h" // SEND
|
||||
|
@ -36,7 +36,7 @@ gen_traverse(PyGenObject *gen, visitproc visit, void *arg)
|
|||
Py_VISIT(gen->gi_name);
|
||||
Py_VISIT(gen->gi_qualname);
|
||||
if (gen->gi_frame_valid) {
|
||||
InterpreterFrame *frame = (InterpreterFrame *)(gen->gi_iframe);
|
||||
_PyInterpreterFrame *frame = (_PyInterpreterFrame *)(gen->gi_iframe);
|
||||
assert(frame->frame_obj == NULL || frame->frame_obj->f_owns_frame == 0);
|
||||
int err = _PyFrame_Traverse(frame, visit, arg);
|
||||
if (err) {
|
||||
|
@ -55,7 +55,7 @@ _PyGen_Finalize(PyObject *self)
|
|||
PyObject *res = NULL;
|
||||
PyObject *error_type, *error_value, *error_traceback;
|
||||
|
||||
if (gen->gi_frame_valid == 0 || _PyFrameHasCompleted((InterpreterFrame *)gen->gi_iframe)) {
|
||||
if (gen->gi_frame_valid == 0 || _PyFrameHasCompleted((_PyInterpreterFrame *)gen->gi_iframe)) {
|
||||
/* Generator isn't paused, so no need to close */
|
||||
return;
|
||||
}
|
||||
|
@ -87,7 +87,7 @@ _PyGen_Finalize(PyObject *self)
|
|||
issue a RuntimeWarning. */
|
||||
if (gen->gi_code != NULL &&
|
||||
((PyCodeObject *)gen->gi_code)->co_flags & CO_COROUTINE &&
|
||||
((InterpreterFrame *)gen->gi_iframe)->f_state == FRAME_CREATED)
|
||||
((_PyInterpreterFrame *)gen->gi_iframe)->f_state == FRAME_CREATED)
|
||||
{
|
||||
_PyErr_WarnUnawaitedCoroutine((PyObject *)gen);
|
||||
}
|
||||
|
@ -131,7 +131,7 @@ gen_dealloc(PyGenObject *gen)
|
|||
Py_CLEAR(((PyAsyncGenObject*)gen)->ag_origin_or_finalizer);
|
||||
}
|
||||
if (gen->gi_frame_valid) {
|
||||
InterpreterFrame *frame = (InterpreterFrame *)gen->gi_iframe;
|
||||
_PyInterpreterFrame *frame = (_PyInterpreterFrame *)gen->gi_iframe;
|
||||
gen->gi_frame_valid = 0;
|
||||
frame->is_generator = false;
|
||||
frame->previous = NULL;
|
||||
|
@ -152,7 +152,7 @@ gen_send_ex2(PyGenObject *gen, PyObject *arg, PyObject **presult,
|
|||
int exc, int closing)
|
||||
{
|
||||
PyThreadState *tstate = _PyThreadState_GET();
|
||||
InterpreterFrame *frame = (InterpreterFrame *)gen->gi_iframe;
|
||||
_PyInterpreterFrame *frame = (_PyInterpreterFrame *)gen->gi_iframe;
|
||||
PyObject *result;
|
||||
|
||||
*presult = NULL;
|
||||
|
@ -348,7 +348,7 @@ _PyGen_yf(PyGenObject *gen)
|
|||
PyObject *yf = NULL;
|
||||
|
||||
if (gen->gi_frame_valid) {
|
||||
InterpreterFrame *frame = (InterpreterFrame *)gen->gi_iframe;
|
||||
_PyInterpreterFrame *frame = (_PyInterpreterFrame *)gen->gi_iframe;
|
||||
PyObject *bytecode = gen->gi_code->co_code;
|
||||
unsigned char *code = (unsigned char *)PyBytes_AS_STRING(bytecode);
|
||||
|
||||
|
@ -377,7 +377,7 @@ gen_close(PyGenObject *gen, PyObject *args)
|
|||
int err = 0;
|
||||
|
||||
if (yf) {
|
||||
InterpreterFrame *frame = (InterpreterFrame *)gen->gi_iframe;
|
||||
_PyInterpreterFrame *frame = (_PyInterpreterFrame *)gen->gi_iframe;
|
||||
PyFrameState state = frame->f_state;
|
||||
frame->f_state = FRAME_EXECUTING;
|
||||
err = gen_close_iter(yf);
|
||||
|
@ -418,7 +418,7 @@ _gen_throw(PyGenObject *gen, int close_on_genexit,
|
|||
PyObject *yf = _PyGen_yf(gen);
|
||||
|
||||
if (yf) {
|
||||
InterpreterFrame *frame = (InterpreterFrame *)gen->gi_iframe;
|
||||
_PyInterpreterFrame *frame = (_PyInterpreterFrame *)gen->gi_iframe;
|
||||
PyObject *ret;
|
||||
int err;
|
||||
if (PyErr_GivenExceptionMatches(typ, PyExc_GeneratorExit) &&
|
||||
|
@ -445,7 +445,7 @@ _gen_throw(PyGenObject *gen, int close_on_genexit,
|
|||
will be reported correctly to the user. */
|
||||
/* XXX We should probably be updating the current frame
|
||||
somewhere in ceval.c. */
|
||||
InterpreterFrame *prev = tstate->cframe->current_frame;
|
||||
_PyInterpreterFrame *prev = tstate->cframe->current_frame;
|
||||
frame->previous = prev;
|
||||
tstate->cframe->current_frame = frame;
|
||||
/* Close the generator that we are currently iterating with
|
||||
|
@ -479,7 +479,7 @@ _gen_throw(PyGenObject *gen, int close_on_genexit,
|
|||
PyObject *val;
|
||||
/* Pop subiterator from stack */
|
||||
assert(gen->gi_frame_valid);
|
||||
ret = _PyFrame_StackPop((InterpreterFrame *)gen->gi_iframe);
|
||||
ret = _PyFrame_StackPop((_PyInterpreterFrame *)gen->gi_iframe);
|
||||
assert(ret == yf);
|
||||
Py_DECREF(ret);
|
||||
/* Termination repetition of SEND loop */
|
||||
|
@ -750,7 +750,7 @@ gen_getrunning(PyGenObject *gen, void *Py_UNUSED(ignored))
|
|||
if (gen->gi_frame_valid == 0) {
|
||||
Py_RETURN_FALSE;
|
||||
}
|
||||
return PyBool_FromLong(_PyFrame_IsExecuting((InterpreterFrame *)gen->gi_iframe));
|
||||
return PyBool_FromLong(_PyFrame_IsExecuting((_PyInterpreterFrame *)gen->gi_iframe));
|
||||
}
|
||||
|
||||
static PyObject *
|
||||
|
@ -759,7 +759,7 @@ gen_getsuspended(PyGenObject *gen, void *Py_UNUSED(ignored))
|
|||
if (gen->gi_frame_valid == 0) {
|
||||
Py_RETURN_FALSE;
|
||||
}
|
||||
return PyBool_FromLong(((InterpreterFrame *)gen->gi_iframe)->f_state == FRAME_SUSPENDED);
|
||||
return PyBool_FromLong(((_PyInterpreterFrame *)gen->gi_iframe)->f_state == FRAME_SUSPENDED);
|
||||
}
|
||||
|
||||
static PyObject *
|
||||
|
@ -771,7 +771,7 @@ _gen_getframe(PyGenObject *gen, const char *const name)
|
|||
if (gen->gi_frame_valid == 0) {
|
||||
Py_RETURN_NONE;
|
||||
}
|
||||
return _Py_XNewRef((PyObject *)_PyFrame_GetFrameObject((InterpreterFrame *)gen->gi_iframe));
|
||||
return _Py_XNewRef((PyObject *)_PyFrame_GetFrameObject((_PyInterpreterFrame *)gen->gi_iframe));
|
||||
}
|
||||
|
||||
static PyObject *
|
||||
|
@ -802,7 +802,7 @@ static PyObject *
|
|||
gen_sizeof(PyGenObject *gen, PyObject *Py_UNUSED(ignored))
|
||||
{
|
||||
Py_ssize_t res;
|
||||
res = offsetof(PyGenObject, gi_iframe) + offsetof(InterpreterFrame, localsplus);
|
||||
res = offsetof(PyGenObject, gi_iframe) + offsetof(_PyInterpreterFrame, localsplus);
|
||||
PyCodeObject *code = gen->gi_code;
|
||||
res += (code->co_nlocalsplus+code->co_stacksize) * sizeof(PyObject *);
|
||||
return PyLong_FromSsize_t(res);
|
||||
|
@ -831,7 +831,7 @@ PyTypeObject PyGen_Type = {
|
|||
PyVarObject_HEAD_INIT(&PyType_Type, 0)
|
||||
"generator", /* tp_name */
|
||||
offsetof(PyGenObject, gi_iframe) +
|
||||
offsetof(InterpreterFrame, localsplus), /* tp_basicsize */
|
||||
offsetof(_PyInterpreterFrame, localsplus), /* tp_basicsize */
|
||||
sizeof(PyObject *), /* tp_itemsize */
|
||||
/* methods */
|
||||
(destructor)gen_dealloc, /* tp_dealloc */
|
||||
|
@ -905,7 +905,7 @@ make_gen(PyTypeObject *type, PyFunctionObject *func)
|
|||
}
|
||||
|
||||
static PyObject *
|
||||
compute_cr_origin(int origin_depth, InterpreterFrame *current_frame);
|
||||
compute_cr_origin(int origin_depth, _PyInterpreterFrame *current_frame);
|
||||
|
||||
PyObject *
|
||||
_Py_MakeCoro(PyFunctionObject *func)
|
||||
|
@ -964,8 +964,8 @@ gen_new_with_qualname(PyTypeObject *type, PyFrameObject *f,
|
|||
/* Copy the frame */
|
||||
assert(f->f_frame->frame_obj == NULL);
|
||||
assert(f->f_owns_frame);
|
||||
InterpreterFrame *frame = (InterpreterFrame *)gen->gi_iframe;
|
||||
_PyFrame_Copy((InterpreterFrame *)f->_f_frame_data, frame);
|
||||
_PyInterpreterFrame *frame = (_PyInterpreterFrame *)gen->gi_iframe;
|
||||
_PyFrame_Copy((_PyInterpreterFrame *)f->_f_frame_data, frame);
|
||||
gen->gi_frame_valid = 1;
|
||||
assert(frame->frame_obj == f);
|
||||
f->f_owns_frame = 0;
|
||||
|
@ -1108,7 +1108,7 @@ cr_getsuspended(PyCoroObject *coro, void *Py_UNUSED(ignored))
|
|||
if (coro->cr_frame_valid == 0) {
|
||||
Py_RETURN_FALSE;
|
||||
}
|
||||
return PyBool_FromLong(((InterpreterFrame *)coro->cr_iframe)->f_state == FRAME_SUSPENDED);
|
||||
return PyBool_FromLong(((_PyInterpreterFrame *)coro->cr_iframe)->f_state == FRAME_SUSPENDED);
|
||||
}
|
||||
|
||||
static PyObject *
|
||||
|
@ -1117,7 +1117,7 @@ cr_getrunning(PyCoroObject *coro, void *Py_UNUSED(ignored))
|
|||
if (coro->cr_frame_valid == 0) {
|
||||
Py_RETURN_FALSE;
|
||||
}
|
||||
return PyBool_FromLong(_PyFrame_IsExecuting((InterpreterFrame *)coro->cr_iframe));
|
||||
return PyBool_FromLong(_PyFrame_IsExecuting((_PyInterpreterFrame *)coro->cr_iframe));
|
||||
}
|
||||
|
||||
static PyObject *
|
||||
|
@ -1176,7 +1176,7 @@ PyTypeObject PyCoro_Type = {
|
|||
PyVarObject_HEAD_INIT(&PyType_Type, 0)
|
||||
"coroutine", /* tp_name */
|
||||
offsetof(PyCoroObject, cr_iframe) +
|
||||
offsetof(InterpreterFrame, localsplus), /* tp_basicsize */
|
||||
offsetof(_PyInterpreterFrame, localsplus), /* tp_basicsize */
|
||||
sizeof(PyObject *), /* tp_itemsize */
|
||||
/* methods */
|
||||
(destructor)gen_dealloc, /* tp_dealloc */
|
||||
|
@ -1314,9 +1314,9 @@ PyTypeObject _PyCoroWrapper_Type = {
|
|||
};
|
||||
|
||||
static PyObject *
|
||||
compute_cr_origin(int origin_depth, InterpreterFrame *current_frame)
|
||||
compute_cr_origin(int origin_depth, _PyInterpreterFrame *current_frame)
|
||||
{
|
||||
InterpreterFrame *frame = current_frame;
|
||||
_PyInterpreterFrame *frame = current_frame;
|
||||
/* First count how many frames we have */
|
||||
int frame_count = 0;
|
||||
for (; frame && frame_count < origin_depth; ++frame_count) {
|
||||
|
@ -1567,7 +1567,7 @@ PyTypeObject PyAsyncGen_Type = {
|
|||
PyVarObject_HEAD_INIT(&PyType_Type, 0)
|
||||
"async_generator", /* tp_name */
|
||||
offsetof(PyAsyncGenObject, ag_iframe) +
|
||||
offsetof(InterpreterFrame, localsplus), /* tp_basicsize */
|
||||
offsetof(_PyInterpreterFrame, localsplus), /* tp_basicsize */
|
||||
sizeof(PyObject *), /* tp_itemsize */
|
||||
/* methods */
|
||||
(destructor)gen_dealloc, /* tp_dealloc */
|
||||
|
@ -2053,7 +2053,7 @@ static PyObject *
|
|||
async_gen_athrow_send(PyAsyncGenAThrow *o, PyObject *arg)
|
||||
{
|
||||
PyGenObject *gen = (PyGenObject*)o->agt_gen;
|
||||
InterpreterFrame *frame = (InterpreterFrame *)gen->gi_iframe;
|
||||
_PyInterpreterFrame *frame = (_PyInterpreterFrame *)gen->gi_iframe;
|
||||
PyObject *retval;
|
||||
|
||||
if (o->agt_state == AWAITABLE_STATE_CLOSED) {
|
||||
|
|
|
@ -12,7 +12,7 @@
|
|||
#include "pycore_typeobject.h" // struct type_cache
|
||||
#include "pycore_unionobject.h" // _Py_union_type_or
|
||||
#include "frameobject.h" // PyFrameObject
|
||||
#include "pycore_frame.h" // InterpreterFrame
|
||||
#include "pycore_frame.h" // _PyInterpreterFrame
|
||||
#include "opcode.h" // MAKE_CELL
|
||||
#include "structmember.h" // PyMemberDef
|
||||
|
||||
|
@ -8933,7 +8933,7 @@ super_descr_get(PyObject *self, PyObject *obj, PyObject *type)
|
|||
}
|
||||
|
||||
static int
|
||||
super_init_without_args(InterpreterFrame *cframe, PyCodeObject *co,
|
||||
super_init_without_args(_PyInterpreterFrame *cframe, PyCodeObject *co,
|
||||
PyTypeObject **type_p, PyObject **obj_p)
|
||||
{
|
||||
if (co->co_argcount == 0) {
|
||||
|
@ -9017,7 +9017,7 @@ super_init(PyObject *self, PyObject *args, PyObject *kwds)
|
|||
/* Call super(), without args -- fill in from __class__
|
||||
and first local variable on the stack. */
|
||||
PyThreadState *tstate = _PyThreadState_GET();
|
||||
InterpreterFrame *cframe = tstate->cframe->current_frame;
|
||||
_PyInterpreterFrame *cframe = tstate->cframe->current_frame;
|
||||
if (cframe == NULL) {
|
||||
PyErr_SetString(PyExc_RuntimeError,
|
||||
"super(): no current frame");
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue