Skip to content
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_state to fdata->state
  • Loading branch information
ncoghlan committed Mar 19, 2022
commit 40156aad440cfe8f3ff7a0598019071c9e442e69
12 changes: 6 additions & 6 deletions Include/internal/pycore_frame.h
Original file line number Diff line number Diff line change
Expand Up @@ -74,7 +74,7 @@ extern PyFrameObject* _PyFrame_New_NoTrack(PyCodeObject *code);
/* other API */

/* These values are chosen so that the inline functions below all
* compare f_state to zero.
* compare the current frame state to zero.
*/
enum _framestate {
FRAME_CREATED = -2,
Expand Down Expand Up @@ -103,22 +103,22 @@ typedef struct _Py_frame {
struct _Py_frame *previous;
int lasti; /* Last instruction if called */
int stacktop; /* Offset of TOS from localsplus */
PyFrameState f_state; /* What state the frame is in */
PyFrameState state; /* What state the frame is in */
bool is_entry; // Whether this is the "root" frame for the current _PyCFrame.
bool is_generator;
PyObject *localsplus[1];
} _Py_frame;

static inline int _PyFrame_IsRunnable(_Py_frame *f) {
return f->f_state < FRAME_EXECUTING;
return f->state < FRAME_EXECUTING;
}

static inline int _PyFrame_IsExecuting(_Py_frame *f) {
return f->f_state == FRAME_EXECUTING;
return f->state == FRAME_EXECUTING;
}

static inline int _PyFrameHasCompleted(_Py_frame *f) {
return f->f_state > FRAME_EXECUTING;
return f->state > FRAME_EXECUTING;
}

static inline PyObject **_PyFrame_Stackbase(_Py_frame *f) {
Expand Down Expand Up @@ -160,7 +160,7 @@ _PyFrame_InitializeSpecials(
frame->stacktop = nlocalsplus;
frame->frame_obj = NULL;
frame->lasti = -1;
frame->f_state = FRAME_CREATED;
frame->state = FRAME_CREATED;
frame->is_entry = false;
frame->is_generator = false;
}
Expand Down
10 changes: 5 additions & 5 deletions Objects/frameobject.c
Original file line number Diff line number Diff line change
Expand Up @@ -442,7 +442,7 @@ frame_setlineno(PyFrameObject *f, PyObject* p_new_lineno, void *Py_UNUSED(ignore
* In addition, jumps are forbidden when not tracing,
* as this is a debugging feature.
*/
switch(f->f_frame->f_state) {
switch(f->f_frame->state) {
case FRAME_CREATED:
PyErr_Format(PyExc_ValueError,
"can't jump from the 'call' trace event of a new frame");
Expand Down Expand Up @@ -550,7 +550,7 @@ frame_setlineno(PyFrameObject *f, PyObject* p_new_lineno, void *Py_UNUSED(ignore
return -1;
}
/* Unwind block stack. */
if (f->f_frame->f_state == FRAME_SUSPENDED) {
if (f->f_frame->state == FRAME_SUSPENDED) {
/* Account for value popped by yield */
start_stack = pop_value(start_stack);
}
Expand Down Expand Up @@ -668,7 +668,7 @@ frame_tp_clear(PyFrameObject *f)
* frame may also point to this frame, believe itself to still be
* active, and try cleaning up this frame again.
*/
f->f_frame->f_state = FRAME_CLEARED;
f->f_frame->state = FRAME_CLEARED;

Py_CLEAR(f->f_trace);

Expand Down Expand Up @@ -891,7 +891,7 @@ _PyFrame_FastToLocalsWithError(_Py_frame *frame) {

PyObject *name = PyTuple_GET_ITEM(co->co_localsplusnames, i);
PyObject *value = fast[i];
if (frame->f_state != FRAME_CLEARED) {
if (frame->state != FRAME_CLEARED) {
if (kind & CO_FAST_FREE) {
// The cell was set by COPY_FREE_VARS.
assert(value != NULL && PyCell_Check(value));
Expand Down Expand Up @@ -1028,7 +1028,7 @@ _PyFrame_LocalsToFast(_Py_frame *frame, int clear)
void
PyFrame_LocalsToFast(PyFrameObject *f, int clear)
{
if (f == NULL || f->f_frame->f_state == FRAME_CLEARED) {
if (f == NULL || f->f_frame->state == FRAME_CLEARED) {
return;
}
_PyFrame_LocalsToFast(f->f_frame, clear);
Expand Down
32 changes: 16 additions & 16 deletions Objects/genobject.c
Original file line number Diff line number Diff line change
Expand Up @@ -87,7 +87,7 @@ _PyGen_Finalize(PyObject *self)
issue a RuntimeWarning. */
if (gen->gi_code != NULL &&
((PyCodeObject *)gen->gi_code)->co_flags & CO_COROUTINE &&
((_Py_frame *)gen->gi_iframe)->f_state == FRAME_CREATED)
((_Py_frame *)gen->gi_iframe)->state == FRAME_CREATED)
{
_PyErr_WarnUnawaitedCoroutine((PyObject *)gen);
}
Expand Down Expand Up @@ -156,7 +156,7 @@ gen_send_ex2(PyGenObject *gen, PyObject *arg, PyObject **presult,
PyObject *result;

*presult = NULL;
if (frame->f_state == FRAME_CREATED && arg && arg != Py_None) {
if (frame->state == FRAME_CREATED && arg && arg != Py_None) {
const char *msg = "can't send non-None value to a "
"just-started generator";
if (PyCoro_CheckExact(gen)) {
Expand Down Expand Up @@ -381,10 +381,10 @@ gen_close(PyGenObject *gen, PyObject *args)

if (yf) {
_Py_frame *frame = (_Py_frame *)gen->gi_iframe;
PyFrameState state = frame->f_state;
frame->f_state = FRAME_EXECUTING;
PyFrameState state = frame->state;
frame->state = FRAME_EXECUTING;
err = gen_close_iter(yf);
frame->f_state = state;
frame->state = state;
Py_DECREF(yf);
}
if (err == 0)
Expand Down Expand Up @@ -431,10 +431,10 @@ _gen_throw(PyGenObject *gen, int close_on_genexit,
We have to allow some awaits to work it through, hence the
`close_on_genexit` parameter here.
*/
PyFrameState state = frame->f_state;
frame->f_state = FRAME_EXECUTING;
PyFrameState state = frame->state;
frame->state = FRAME_EXECUTING;
err = gen_close_iter(yf);
frame->f_state = state;
frame->state = state;
Py_DECREF(yf);
if (err < 0)
return gen_send_ex(gen, Py_None, 1, 0);
Expand All @@ -453,11 +453,11 @@ _gen_throw(PyGenObject *gen, int close_on_genexit,
tstate->cframe->current_frame = frame;
/* Close the generator that we are currently iterating with
'yield from' or awaiting on with 'await'. */
PyFrameState state = frame->f_state;
frame->f_state = FRAME_EXECUTING;
PyFrameState state = frame->state;
frame->state = FRAME_EXECUTING;
ret = _gen_throw((PyGenObject *)yf, close_on_genexit,
typ, val, tb);
frame->f_state = state;
frame->state = state;
tstate->cframe->current_frame = prev;
frame->previous = NULL;
} else {
Expand All @@ -471,10 +471,10 @@ _gen_throw(PyGenObject *gen, int close_on_genexit,
Py_DECREF(yf);
goto throw_here;
}
PyFrameState state = frame->f_state;
frame->f_state = FRAME_EXECUTING;
PyFrameState state = frame->state;
frame->state = FRAME_EXECUTING;
ret = PyObject_CallFunctionObjArgs(meth, typ, val, tb, NULL);
frame->f_state = state;
frame->state = state;
Py_DECREF(meth);
}
Py_DECREF(yf);
Expand Down Expand Up @@ -769,7 +769,7 @@ gen_getsuspended(PyGenObject *gen, void *Py_UNUSED(ignored))
if (gen->gi_frame_valid == 0) {
Py_RETURN_FALSE;
}
return PyBool_FromLong(((_Py_frame *)gen->gi_iframe)->f_state == FRAME_SUSPENDED);
return PyBool_FromLong(((_Py_frame *)gen->gi_iframe)->state == FRAME_SUSPENDED);
}

static PyObject *
Expand Down Expand Up @@ -1118,7 +1118,7 @@ cr_getsuspended(PyCoroObject *coro, void *Py_UNUSED(ignored))
if (coro->cr_frame_valid == 0) {
Py_RETURN_FALSE;
}
return PyBool_FromLong(((_Py_frame *)coro->cr_iframe)->f_state == FRAME_SUSPENDED);
return PyBool_FromLong(((_Py_frame *)coro->cr_iframe)->state == FRAME_SUSPENDED);
}

static PyObject *
Expand Down
20 changes: 10 additions & 10 deletions Python/ceval.c
Original file line number Diff line number Diff line change
Expand Up @@ -1739,7 +1739,7 @@ _PyEval_EvalFrameDefault(PyThreadState *tstate, _Py_frame *frame, int throwflag)
PREDICTED(RESUME_QUICK);
assert(tstate->cframe == &cframe);
assert(frame == cframe.current_frame);
frame->f_state = FRAME_EXECUTING;
frame->state = FRAME_EXECUTING;
if (_Py_atomic_load_relaxed(eval_breaker) && oparg < 2) {
goto handle_eval_breaker;
}
Expand Down Expand Up @@ -2382,7 +2382,7 @@ _PyEval_EvalFrameDefault(PyThreadState *tstate, _Py_frame *frame, int throwflag)
TARGET(RETURN_VALUE) {
PyObject *retval = POP();
assert(EMPTY());
frame->f_state = FRAME_RETURNED;
frame->state = FRAME_RETURNED;
_PyFrame_SetStackPointer(frame, stack_pointer);
TRACE_FUNCTION_EXIT();
DTRACE_FUNCTION_EXIT();
Expand Down Expand Up @@ -2594,7 +2594,7 @@ _PyEval_EvalFrameDefault(PyThreadState *tstate, _Py_frame *frame, int throwflag)
TARGET(YIELD_VALUE) {
assert(frame->is_entry);
PyObject *retval = POP();
frame->f_state = FRAME_SUSPENDED;
frame->state = FRAME_SUSPENDED;
_PyFrame_SetStackPointer(frame, stack_pointer);
TRACE_FUNCTION_EXIT();
DTRACE_FUNCTION_EXIT();
Expand Down Expand Up @@ -4086,7 +4086,7 @@ _PyEval_EvalFrameDefault(PyThreadState *tstate, _Py_frame *frame, int throwflag)
* generator or coroutine, so we deliberately do not check it here.
* (see bpo-30039).
*/
frame->f_state = FRAME_EXECUTING;
frame->state = FRAME_EXECUTING;
JUMPTO(oparg);
DISPATCH();
}
Expand Down Expand Up @@ -5273,7 +5273,7 @@ _PyEval_EvalFrameDefault(PyThreadState *tstate, _Py_frame *frame, int throwflag)
assert(frame->frame_obj == NULL);
gen->gi_frame_valid = 1;
gen_frame->is_generator = true;
gen_frame->f_state = FRAME_CREATED;
gen_frame->state = FRAME_CREATED;
_Py_LeaveRecursiveCall(tstate);
if (!frame->is_entry) {
_Py_frame *prev = frame->previous;
Expand Down Expand Up @@ -5454,7 +5454,7 @@ _PyEval_EvalFrameDefault(PyThreadState *tstate, _Py_frame *frame, int throwflag)
TRACE_FUNCTION_ENTRY();
DTRACE_FUNCTION_ENTRY();
}
else if (frame->f_state > FRAME_CREATED) {
else if (frame->state > FRAME_CREATED) {
/* line-by-line tracing support */
if (PyDTrace_LINE_ENABLED()) {
maybe_dtrace_line(frame, &tstate->trace_info, instr_prev);
Expand Down Expand Up @@ -5575,13 +5575,13 @@ MISS_WITH_INLINE_CACHE(STORE_SUBSCR)

if (tstate->c_tracefunc != NULL) {
/* Make sure state is set to FRAME_UNWINDING for tracing */
frame->f_state = FRAME_UNWINDING;
frame->state = FRAME_UNWINDING;
call_exc_trace(tstate->c_tracefunc, tstate->c_traceobj,
tstate, frame);
}

exception_unwind:
frame->f_state = FRAME_UNWINDING;
frame->state = FRAME_UNWINDING;
/* We can't use frame->lasti here, as RERAISE may have set it */
int offset = INSTR_OFFSET()-1;
int level, handler, lasti;
Expand All @@ -5597,7 +5597,7 @@ MISS_WITH_INLINE_CACHE(STORE_SUBSCR)
}
assert(STACK_LEVEL() == 0);
_PyFrame_SetStackPointer(frame, stack_pointer);
frame->f_state = FRAME_RAISED;
frame->state = FRAME_RAISED;
TRACE_FUNCTION_UNWIND();
DTRACE_FUNCTION_EXIT();
goto exit_unwind;
Expand Down Expand Up @@ -5632,7 +5632,7 @@ MISS_WITH_INLINE_CACHE(STORE_SUBSCR)
PUSH(val);
JUMPTO(handler);
/* Resume normal execution */
frame->f_state = FRAME_EXECUTING;
frame->state = FRAME_EXECUTING;
DISPATCH();
}

Expand Down