Skip to content

Commit 2c83732

Browse files
committed
[mypyc] Use PyGen_GetCode in gen_is_coroutine
1 parent 0c10dc3 commit 2c83732

File tree

1 file changed

+2
-32
lines changed

1 file changed

+2
-32
lines changed

mypyc/lib-rt/pythonsupport.h

Lines changed: 2 additions & 32 deletions
Original file line numberDiff line numberDiff line change
@@ -405,45 +405,15 @@ _CPyObject_HasAttrId(PyObject *v, _Py_Identifier *name) {
405405
PyObject_CallMethodObjArgs((self), (name), (arg), NULL)
406406
#endif
407407

408-
#if CPY_3_13_FEATURES
409-
410-
// These are copied from genobject.c in Python 3.13
411-
412-
/* Returns a borrowed reference */
413-
static inline PyCodeObject *
414-
_PyGen_GetCode(PyGenObject *gen) {
415-
_PyInterpreterFrame *frame = (_PyInterpreterFrame *)(gen->gi_iframe);
416-
return _PyFrame_GetCode(frame);
417-
}
418-
419-
static int
420-
gen_is_coroutine(PyObject *o)
421-
{
422-
if (PyGen_CheckExact(o)) {
423-
PyCodeObject *code = _PyGen_GetCode((PyGenObject*)o);
424-
if (code->co_flags & CO_ITERABLE_COROUTINE) {
425-
return 1;
426-
}
427-
}
428-
return 0;
429-
}
430-
431-
#elif CPY_3_12_FEATURES
408+
#if CPY_3_12_FEATURES
432409

433410
// These are copied from genobject.c in Python 3.12
434411

435-
/* Returns a borrowed reference */
436-
static inline PyCodeObject *
437-
_PyGen_GetCode(PyGenObject *gen) {
438-
_PyInterpreterFrame *frame = (_PyInterpreterFrame *)(gen->gi_iframe);
439-
return frame->f_code;
440-
}
441-
442412
static int
443413
gen_is_coroutine(PyObject *o)
444414
{
445415
if (PyGen_CheckExact(o)) {
446-
PyCodeObject *code = _PyGen_GetCode((PyGenObject*)o);
416+
PyCodeObject *code = PyGen_GetCode((PyGenObject*)o);
447417
if (code->co_flags & CO_ITERABLE_COROUTINE) {
448418
return 1;
449419
}

0 commit comments

Comments
 (0)