Skip to content

Commit a22412c

Browse files
committed
minor tidy ups to genobject.c
1 parent 15a965e commit a22412c

File tree

1 file changed

+3
-4
lines changed

1 file changed

+3
-4
lines changed

Objects/genobject.c

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -456,6 +456,7 @@ _gen_throw(PyGenObject *gen, int close_on_genexit,
456456
if (!ret) {
457457
PyObject *val;
458458
/* Pop subiterator from stack */
459+
assert(gen->gi_frame->f_stackdepth > 0);
459460
gen->gi_frame->f_stackdepth--;
460461
ret = gen->gi_frame->f_valuestack[gen->gi_frame->f_stackdepth];
461462
assert(ret == yf);
@@ -712,8 +713,7 @@ static PyObject *
712713
gen_getrunning(PyGenObject *gen, void *Py_UNUSED(ignored))
713714
{
714715
if (gen->gi_frame == NULL) {
715-
Py_INCREF(Py_False);
716-
return Py_False;
716+
Py_RETURN_FALSE;
717717
}
718718
return PyBool_FromLong(_PyFrame_IsExecuting(gen->gi_frame));
719719
}
@@ -941,8 +941,7 @@ static PyObject *
941941
cr_getrunning(PyCoroObject *coro, void *Py_UNUSED(ignored))
942942
{
943943
if (coro->cr_frame == NULL) {
944-
Py_INCREF(Py_False);
945-
return Py_False;
944+
Py_RETURN_FALSE;
946945
}
947946
return PyBool_FromLong(_PyFrame_IsExecuting(coro->cr_frame));
948947
}

0 commit comments

Comments
 (0)