10000 bpo-44800: rename _PyInterpreterFrame to _Py_frame by ncoghlan · Pull Request #31987 · python/cpython · GitHub
[go: up one dir, main page]

Skip to content

bpo-44800: rename _PyInterpreterFrame to _Py_frame #31987

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
Rename fdata->f_code to fdata->code
  • Loading branch information
ncoghlan committed Mar 19, 2022
commit c16b2c42602c6fc485a6f3de84d002b7b94e30c1
10 changes: 5 additions & 5 deletions Include/internal/pycore_frame.h
Original file line number Diff line number Diff line change
Expand Up @@ -98,7 +98,7 @@ typedef struct _Py_frame {
PyObject *globals; /* Borrowed reference */
PyObject *builtins; /* Borrowed reference */
PyObject *locals; /* Strong reference, may be NULL */
PyCodeObject *f_code; /* Strong reference */
PyCodeObject *code; /* Strong reference */
PyFrameObject *frame_obj; /* Strong reference, may be NULL */
struct _Py_frame *previous;
in 8000 t f_lasti; /* Last instruction if called */
Expand All @@ -122,17 +122,17 @@ static inline int _PyFrameHasCompleted(_Py_frame *f) {
}

static inline PyObject **_PyFrame_Stackbase(_Py_frame *f) {
return f->localsplus + f->f_code->co_nlocalsplus;
return f->localsplus + f->code->co_nlocalsplus;
}

static inline PyObject *_PyFrame_StackPeek(_Py_frame *f) {
assert(f->stacktop > f->f_code->co_nlocalsplus);
assert(f->stacktop > f->code->co_nlocalsplus);
assert(f->localsplus[f->stacktop-1] != NULL);
return f->localsplus[f->stacktop-1];
}

static inline PyObject *_PyFrame_StackPop(_Py_frame *f) {
assert(f->stacktop > f->f_code->co_nlocalsplus);
assert(f->stacktop > f->code->co_nlocalsplus);
f->stacktop--;
return f->localsplus[f->stacktop];
}
Expand All @@ -153,7 +153,7 @@ _PyFrame_InitializeSpecials(
PyObject *locals, int nlocalsplus)
{
frame->func = func;
frame->f_code = (PyCodeObject *)Py_NewRef(func->func_code);
frame->code = (PyCodeObject *)Py_NewRef(func->func_code);
frame->builtins = func->func_builtins;
frame->globals = func->func_globals;
frame->locals = Py_XNewRef(locals);
Expand Down
10 changes: 5 additions & 5 deletions Misc/gdbinit
Original file line number Diff line number Diff line change
Expand Up @@ -37,9 +37,9 @@ end

define pylocals
set $_i = 0
while $_i < f->f_code->co_nlocals
while $_i < f->code->co_nlocals
if f->f_localsplus + $_i != 0
set $_names = f->f_code->co_varnames
set $_names = f->code->co_varnames
set $_name = PyUnicode_AsUTF8(PyTuple_GetItem($_names, $_i))
printf "%s:\n", $_name
pyo f->f_localsplus[$_i]
Expand All @@ -55,7 +55,7 @@ end
# command language
define lineno
set $__continue = 1
set $__co = f->f_code
set $__co = f->code
set $__lasti = f->f_lasti
set $__sz = ((PyVarObject *)$__co->co_lnotab)->ob_size/2
set $__p = (unsigned char *)((PyBytesObject *)$__co->co_lnotab)->ob_sval
Expand Down Expand Up @@ -84,8 +84,8 @@ document pyframev
end

define pyframe
set $__fn = PyUnicode_AsUTF8(f->f_code->co_filename)
set $__n = PyUnicode_AsUTF8(f->f_code->co_name)
set $__fn = PyUnicode_AsUTF8(f->code->co_filename)
set $__n = PyUnicode_AsUTF8(f->code->co_name)
printf "%s (", $__fn
lineno
printf "): %s\n", $__n
Expand Down
4 changes: 2 additions & 2 deletions Modules/_tracemalloc.c
Original file line number Diff line number Diff line change
Expand Up @@ -308,13 +308,13 @@ static void
tracemalloc_get_frame(_Py_frame *pyframe, frame_t *frame)
{
frame->filename = &_Py_STR(anon_unknown);
int lineno = PyCode_Addr2Line(pyframe->f_code, pyframe->f_lasti*sizeof(_Py_CODEUNIT));
int lineno = PyCode_Addr2Line(pyframe->code, pyframe->f_lasti*sizeof(_Py_CODEUNIT));
if (lineno < 0) {
lineno = 0;
}
frame->lineno = (unsigned int)lineno;

PyObject *filename = pyframe->f_code->co_filename;
PyObject *filename = pyframe->code->co_filename;

if (filename == NULL) {
#ifdef TRACE_DEBUG
Expand Down
28 changes: 14 additions & 14 deletions Objects/frameobject.c
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@ PyFrame_GetLineNumber(PyFrameObject *f)
return f->f_lineno;
}
else {
return PyCode_Addr2Line(f->f_frame->f_code, f->f_frame->f_lasti*sizeof(_Py_CODEUNIT));
return PyCode_Addr2Line(f->f_frame->code, f->f_frame->f_lasti*sizeof(_Py_CODEUNIT));
}
}

Expand Down Expand Up @@ -484,7 +484,7 @@ frame_setlineno(PyFrameObject *f, PyObject* p_new_lineno, void *Py_UNUSED(ignore
}
new_lineno = (int)l_new_lineno;

if (new_lineno < f->f_frame->f_code->co_firstlineno) {
if (new_lineno < f->f_frame->code->co_firstlineno) {
PyErr_Format(PyExc_ValueError,
"line %d comes before the current code block",
new_lineno);
Expand All @@ -493,8 +493,8 @@ frame_setlineno(PyFrameObject *f, PyObject* p_new_lineno, void *Py_UNUSED(ignore

/* PyCode_NewWithPosOnlyArgs limits co_code to be under INT_MAX so this
* should never overflow. */
int len = (int)(PyBytes_GET_SIZE(f->f_frame->f_code->co_code) / sizeof(_Py_CODEUNIT));
int *lines = marklines(f->f_frame->f_code, len);
int len = (int)(PyBytes_GET_SIZE(f->f_frame->code->co_code) / sizeof(_Py_CODEUNIT));
int *lines = marklines(f->f_frame->code, len);
if (lines == NULL) {
return -1;
}
Expand All @@ -508,7 +508,7 @@ frame_setlineno(PyFrameObject *f, PyObject* p_new_lineno, void *Py_UNUSED(ignore
return -1;
}

int64_t *stacks = mark_stacks(f->f_frame->f_code, len);
int64_t *stacks = mark_stacks(f->f_frame->code, len);
if (stacks == NULL) {
PyMem_Free(lines);
return -1;
Expand Down Expand Up @@ -632,8 +632,8 @@ frame_dealloc(PyFrameObject *f)
assert(f->f_frame == (_Py_frame *)f->_f_frame_data);
_Py_frame *frame = (_Py_frame *)f->_f_frame_data;
/* Don't clear code object until the end */
co = frame->f_code;
frame->f_code = NULL;
co = frame->code;
frame->code = NULL;
Py_CLEAR(frame->func);
Py_CLEAR(frame->locals);
PyObject **locals = _PyFrame_GetLocalsArray(frame);
Expand Down Expand Up @@ -708,7 +708,7 @@ frame_sizeof(PyFrameObject *f, PyObject *Py_UNUSED(ignored))
{
Py_ssize_t res;
res = offsetof(PyFrameObject, _f_frame_data) + offsetof(_Py_frame, localsplus);
PyCodeObject *code = f->f_frame->f_code;
PyCodeObject *code = f->f_frame->code;
res += (code->co_nlocalsplus+code->co_stacksize) * sizeof(PyObject *);
return PyLong_FromSsize_t(res);
}
Expand All @@ -720,7 +720,7 @@ static PyObject *
frame_repr(PyFrameObject *f)
{
int lineno = PyFrame_GetLineNumber(f);
PyCodeObject *code = f->f_frame->f_code;
PyCodeObject *code = f->f_frame->code;
return PyUnicode_FromFormat(
"<frame at %p, file %R, line %d, code %S>",
f, code->co_filename, lineno, code->co_name);
Expand Down Expand Up @@ -839,7 +839,7 @@ static int
_PyFrame_OpAlreadyRan(_Py_frame *frame, int opcode, int oparg)
{
const _Py_CODEUNIT *code =
(const _Py_CODEUNIT *)PyBytes_AS_STRING(frame->f_code->co_code);
(const _Py_CODEUNIT *)PyBytes_AS_STRING(frame->code->co_code);
for (int i = 0; i < frame->f_lasti; i++) {
if (_Py_OPCODE(code[i]) == opcode && _Py_OPARG(code[i]) == oparg) {
return 1;
Expand All @@ -860,11 +860,11 @@ _PyFrame_FastToLocalsWithError(_Py_frame *frame) {
if (locals == NULL)
return -1;
}
co = frame->f_code;
co = frame->code;
fast = _PyFrame_GetLocalsArray(frame);
if (frame->f_lasti < 0 && _Py_OPCODE(co->co_firstinstr[0]) == COPY_FREE_VARS) {
/* Free vars have not been initialized -- Do that */
PyCodeObject *co = frame->f_code;
PyCodeObject *co = frame->code;
PyObject *closure = frame->func->func_closure;
int offset = co->co_nlocals + co->co_nplaincellvars;
for (int i = 0; i < co->co_nfreevars; ++i) {
Expand Down Expand Up @@ -971,7 +971,7 @@ _PyFrame_LocalsToFast(_Py_frame *frame, int clear)
if (locals == NULL)
return;
fast = _PyFrame_GetLocalsArray(frame);
co = frame->f_code;
co = frame->code;

PyErr_Fetch(&error_type, &error_value, &error_traceback);
for (int i = 0; i < co->co_nlocalsplus; i++) {
Expand Down Expand Up @@ -1039,7 +1039,7 @@ PyCodeObject *
PyFrame_GetCode(PyFrameObject *frame)
{
assert(frame != NULL);
PyCodeObject *code = frame->f_frame->f_code;
PyCodeObject *code = frame->f_frame->code;
assert(code != NULL);
Py_INCREF(code);
return code;
Expand Down
6 changes: 3 additions & 3 deletions Objects/genobject.c
Original file line number Diff line number Diff line change
Expand Up @@ -964,7 +964,7 @@ static PyObject *
gen_new_with_qualname(PyTypeObject *type, PyFrameObject *f,
PyObject *name, PyObject *qualname)
{
PyCodeObject *code = f->f_frame->f_code;
PyCodeObject *code = f->f_frame->code;
int size = code->co_nlocalsplus + code->co_stacksize;
PyGenObject *gen = PyObject_GC_NewVar(PyGenObject, type, size);
if (gen == NULL) {
Expand Down Expand Up @@ -1341,10 +1341,10 @@ compute_cr_origin(int origin_depth, _Py_frame *current_frame)
}
frame = current_frame;
for (int i = 0; i < frame_count; ++i) {
PyCodeObject *code = frame->f_code;
PyCodeObject *code = frame->code;
PyObject *frameinfo = Py_BuildValue("OiO",
code->co_filename,
PyCode_Addr2Line(frame->f_code, frame->f_lasti*sizeof(_Py_CODEUNIT)),
PyCode_Addr2Line(frame->code, frame->f_lasti*sizeof(_Py_CODEUNIT)),
code->co_name);
if (!frameinfo) {
Py_DECREF(cr_origin);
Expand Down
4 changes: 2 additions & 2 deletions Objects/typeobject.c
Original file line number Diff line number Diff line change
Expand Up @@ -8942,7 +8942,7 @@ super_init_without_args(_Py_frame *cframe, PyCodeObject *co,
return -1;
}

assert(cframe->f_code->co_nlocalsplus > 0);
assert(cframe->code->co_nlocalsplus > 0);
PyObject *firstarg = _PyFrame_GetLocalsArray(cframe)[0];
// The first argument might be a cell.
if (firstarg != NULL && (_PyLocals_GetKind(co->co_localspluskinds, 0) & CO_FAST_CELL)) {
Expand Down Expand Up @@ -9032,7 +9032,7 @@ super_init_impl(PyObject *self, PyTypeObject *type, PyObject *obj) {
"super(): no current frame");
return -1;
}
int res = super_init_without_args(cframe, cframe->f_code, &type, &obj);
int res = super_init_without_args(cframe, cframe->code, &type, &obj);

if (res < 0) {
return -1;
Expand Down
2 changes: 1 addition & 1 deletion Python/_warnings.c
Original file line number Diff line number Diff line change
Expand Up @@ -849,7 +849,7 @@ setup_context(Py_ssize_t stack_level, PyObject **filename, int *lineno,
}
else {
globals = f->f_frame->globals;
*filename = f->f_frame->f_code->co_filename;
*filename = f->f_frame->code->co_filename;
Py_INCREF(*filename);
*lineno = PyFrame_GetLineNumber(f);
Py_DECREF(f);
Expand Down
Loading
0