8000 Rename fdata->f_code to fdata->code · python/cpython@c16b2c4 · GitHub
[go: up one dir, main page]

Skip to content

Commit c16b2c4

Browse files
committed
Rename fdata->f_code to fdata->code
1 parent c324b81 commit c16b2c4

File tree

11 files changed

+70
-70
lines changed

11 files changed

+70
-70
lines changed

Include/internal/pycore_frame.h

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -98,7 +98,7 @@ typedef struct _Py_frame {
9898
PyObject *globals; /* Borrowed reference */
9999
PyObject *builtins; /* Borrowed reference */
100100
PyObject *locals; /* Strong reference, may be NULL */
101-
PyCodeObject *f_code; /* Strong reference */
101+
PyCodeObject *code; /* Strong reference */
102102
PyFrameObject *frame_obj; /* Strong reference, may be NULL */
103103
struct _Py_frame *previous;
104104
int f_lasti; /* Last instruction if called */
@@ -122,17 +122,17 @@ static inline int _PyFrameHasCompleted(_Py_frame *f) {
122122
}
123123

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

128128
static inline PyObject *_PyFrame_StackPeek(_Py_frame *f) {
129-
assert(f->stacktop > f->f_code->co_nlocalsplus);
129+
assert(f->stacktop > f->code->co_nlocalsplus);
130130
assert(f->localsplus[f->stacktop-1] != NULL);
131131
return f->localsplus[f->stacktop-1];
132132
}
133133

134134
static inline PyObject *_PyFrame_StackPop(_Py_frame *f) {
135-
assert(f->stacktop > f->f_code->co_nlocalsplus);
135+
assert(f->stacktop > f->code->co_nlocalsplus);
136136
f->stacktop--;
137137
return f->localsplus[f->stacktop];
138138
}
@@ -153,7 +153,7 @@ _PyFrame_InitializeSpecials(
153153
PyObject *locals, int nlocalsplus)
154154
{
155155
frame->func = func;
156-
frame->f_code = (PyCodeObject *)Py_NewRef(func->func_code);
156+
frame->code = (PyCodeObject *)Py_NewRef(func->func_code);
157157
frame->builtins = func->func_builtins;
158158
frame->globals = func->func_globals;
159159
frame->locals = Py_XNewRef(locals);

Misc/gdbinit

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -37,9 +37,9 @@ end
3737

3838
define pylocals
3939
set $_i = 0
40-
while $_i < f->f_code->co_nlocals
40+
while $_i < f->code->co_nlocals
4141
if f->f_localsplus + $_i != 0
42-
set $_names = f->f_code->co_varnames
42+
set $_names = f->code->co_varnames
4343
set $_name = PyUnicode_AsUTF8(PyTuple_GetItem($_names, $_i))
4444
printf "%s:\n", $_name
4545
pyo f->f_localsplus[$_i]
@@ -55,7 +55,7 @@ end
5555
# command language
5656
define lineno
5757
set $__continue = 1
58-
set $__co = f->f_code
58+
set $__co = f->code
5959
set $__lasti = f->f_lasti
6060
set $__sz = ((PyVarObject *)$__co->co_lnotab)->ob_size/2
6161
set $__p = (unsigned char *)((PyBytesObject *)$__co->co_lnotab)->ob_sval
@@ -84,8 +84,8 @@ document pyframev
8484
end
8585

8686
define pyframe
87-
set $__fn = PyUnicode_AsUTF8(f->f_code->co_filename)
88-
set $__n = PyUnicode_AsUTF8(f->f_code->co_name)
87+
set $__fn = PyUnicode_AsUTF8(f->code->co_filename)
88+
set $__n = PyUnicode_AsUTF8(f->code->co_name)
8989
printf "%s (", $__fn
9090
lineno
9191
printf "): %s\n", $__n

Modules/_tracemalloc.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -308,13 +308,13 @@ static void
308308
tracemalloc_get_frame(_Py_frame *pyframe, frame_t *frame)
309309
{
310310
frame->filename = &_Py_STR(anon_unknown);
311-
int lineno = PyCode_Addr2Line(pyframe->f_code, pyframe->f_lasti*sizeof(_Py_CODEUNIT));
311+
int lineno = PyCode_Addr2Line(pyframe->code, pyframe->f_lasti*sizeof(_Py_CODEUNIT));
312312
if (lineno < 0) {
313313
lineno = 0;
314314
}
315315
frame->lineno = (unsigned int)lineno;
316316

317-
PyObject *filename = pyframe->f_code->co_filename;
317+
PyObject *filename = pyframe->code->co_filename;
318318

319319
if (filename == NULL) {
320320
#ifdef TRACE_DEBUG

Objects/frameobject.c

Lines changed: 14 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -39,7 +39,7 @@ PyFrame_GetLineNumber(PyFrameObject *f)
3939
return f->f_lineno;
4040
}
4141
else {
42-
return PyCode_Addr2Line(f->f_frame->f_code, f->f_frame->f_lasti*sizeof(_Py_CODEUNIT));
42+
return PyCode_Addr2Line(f->f_frame->code, f->f_frame->f_lasti*sizeof(_Py_CODEUNIT));
4343
}
4444
}
4545

@@ -484,7 +484,7 @@ frame_setlineno(PyFrameObject *f, PyObject* p_new_lineno, void *Py_UNUSED(ignore
484484
}
485485
new_lineno = (int)l_new_lineno;
486486

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

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

511-
int64_t *stacks = mark_stacks(f->f_frame->f_code, len);
511+
int64_t *stacks = mark_stacks(f->f_frame->code, len);
512512
if (stacks == NULL) {
513513
PyMem_Free(lines);
514514
return -1;
@@ -632,8 +632,8 @@ frame_dealloc(PyFrameObject *f)
632632
assert(f->f_frame == (_Py_frame *)f->_f_frame_data);
633633
_Py_frame *frame = (_Py_frame *)f->_f_frame_data;
634634
/* Don't clear code object until the end */
635-
co = frame->f_code;
636-
frame->f_code = NULL;
635+
co = frame->code;
636+
frame->code = NULL;
637637
Py_CLEAR(frame->func);
638638
Py_CLEAR(frame->locals);
639639
PyObject **locals = _PyFrame_GetLocalsArray(frame);
@@ -708,7 +708,7 @@ frame_sizeof(PyFrameObject *f, PyObject *Py_UNUSED(ignored))
708708
{
709709
Py_ssize_t res;
710710
res = offsetof(PyFrameObject, _f_frame_data) + offsetof(_Py_frame, localsplus);
711-
PyCodeObject *code = f->f_frame->f_code;
711+
PyCodeObject *code = f->f_frame->code;
712712
res += (code->co_nlocalsplus+code->co_stacksize) * sizeof(PyObject *);
713713
return PyLong_FromSsize_t(res);
714714
}
@@ -720,7 +720,7 @@ static PyObject *
720720
frame_repr(PyFrameObject *f)
721721
{
722722
int lineno = PyFrame_GetLineNumber(f);
723-
PyCodeObject *code = f->f_frame->f_code;
723+
PyCodeObject *code = f->f_frame->code;
724724
return PyUnicode_FromFormat(
725725
"<frame at %p, file %R, line %d, code %S>",
726726
f, code->co_filename, lineno, code->co_name);
@@ -839,7 +839,7 @@ static int
839839
_PyFrame_OpAlreadyRan(_Py_frame *frame, int opcode, int oparg)
840840
{
841841
const _Py_CODEUNIT *code =
842-
(const _Py_CODEUNIT *)PyBytes_AS_STRING(frame->f_code->co_code);
842+
(const _Py_CODEUNIT *)PyBytes_AS_STRING(frame->code->co_code);
843843
for (int i = 0; i < frame->f_lasti; i++) {
844844
if (_Py_OPCODE(code[i]) == opcode && _Py_OPARG(code[i]) == oparg) {
845845
return 1;
@@ -860,11 +860,11 @@ _PyFrame_FastToLocalsWithError(_Py_frame *frame) {
860860
if (locals == NULL)
861861
return -1;
862862
}
863-
co = frame->f_code;
863+
co = frame->code;
864864
fast = _PyFrame_GetLocalsArray(frame);
865865
if (frame->f_lasti < 0 && _Py_OPCODE(co->co_firstinstr[0]) == COPY_FREE_VARS) {
866866
/* Free vars have not been initialized -- Do that */
867-
PyCodeObject *co = frame->f_code;
867+
PyCodeObject *co = frame->code;
868868
PyObject *closure = frame->func->func_closure;
869869
int offset = co->co_nlocals + co->co_nplaincellvars;
870870
for (int i = 0; i < co->co_nfreevars; ++i) {
@@ -971,7 +971,7 @@ _PyFrame_LocalsToFast(_Py_frame *frame, int clear)
971971
if (locals == NULL)
972972
return;
973973
fast = _PyFrame_GetLocalsArray(frame);
974-
co = frame->f_code;
974+
co = frame->code;
975975

976976
PyErr_Fetch(&error_type, &error_value, &error_traceback);
977977
for (int i = 0; i < co->co_nlocalsplus; i++) {
@@ -1039,7 +1039,7 @@ PyCodeObject *
10391039
PyFrame_GetCode(PyFrameObject *frame)
10401040
{
10411041
assert(frame != NULL);
1042-
PyCodeObject *code = frame->f_frame->f_code;
1042+
PyCodeObject *code = frame->f_frame->code;
10431043
assert(code != NULL);
10441044
Py_INCREF(code);
10451045
return code;

Objects/genobject.c

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -964,7 +964,7 @@ static PyObject *
964964
gen_new_with_qualname(PyTypeObject *type, PyFrameObject *f,
965965
PyObject *name, PyObject *qualname)
966966
{
967-
PyCodeObject *code = f->f_frame->f_code;
967+
PyCodeObject *code = f->f_frame->code;
968968
int size = code->co_nlocalsplus + code->co_stacksize;
969969
PyGenObject *gen = PyObject_GC_NewVar(PyGenObject, type, size);
970970
if (gen == NULL) {
@@ -1341,10 +1341,10 @@ compute_cr_origin(int origin_depth, _Py_frame *current_frame)
13411341
}
13421342
frame = current_frame;
13431343
for (int i = 0; i < frame_count; ++i) {
1344-
PyCodeObject *code = frame->f_code;
1344+
PyCodeObject *code = frame->code;
13451345
PyObject *frameinfo = Py_BuildValue("OiO",
13461346
code->co_filename,
1347-
PyCode_Addr2Line(frame->f_code, frame->f_lasti*sizeof(_Py_CODEUNIT)),
1347+
PyCode_Addr2Line(frame->code, frame->f_lasti*sizeof(_Py_CODEUNIT)),
13481348
code->co_name);
13491349
if (!frameinfo) {
13501350
Py_DECREF(cr_origin);

Objects/typeobject.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -8942,7 +8942,7 @@ super_init_without_args(_Py_frame *cframe, PyCodeObject *co,
89428942
return -1;
89438943
}
89448944

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

90379037
if (res < 0) {
90389038
return -1;

Python/_warnings.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -849,7 +849,7 @@ setup_context(Py_ssize_t stack_level, PyObject **filename, int *lineno,
849849
}
850850
else {
851851
globals = f->f_frame->globals;
852-
*filename = f->f_frame->f_code->co_filename;
852+
*filename = f->f_frame->code->co_filename;
853853
Py_INCREF(*filename);
854854
*lineno = PyFrame_GetLineNumber(f);
855855
Py_DECREF(f);

0 commit comments

Comments
 (0)
0