Skip to content

Commit b0bf36e

Browse files
committed
Fix building with !MICROPY_PY_ASYNC_AWAIT
1 parent 5606d49 commit b0bf36e

3 files changed

Lines changed: 18 additions & 4 deletions

File tree

py/obj.h

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -741,7 +741,9 @@ extern const mp_obj_type_t mp_type_gen_instance;
741741
// CIRCUITPY
742742
extern const mp_obj_type_t mp_type_coro_wrap;
743743
// CIRCUITPY
744+
#if MICROPY_PY_ASYNC_AWAIT
744745
extern const mp_obj_type_t mp_type_coro_instance;
746+
#endif
745747
extern const mp_obj_type_t mp_type_fun_builtin_0;
746748
extern const mp_obj_type_t mp_type_fun_builtin_1;
747749
extern const mp_obj_type_t mp_type_fun_builtin_2;

py/objgenerator.c

Lines changed: 11 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -71,7 +71,12 @@ STATIC mp_obj_t gen_wrap_call(mp_obj_t self_in, size_t n_args, size_t n_kw, cons
7171
// allocate the generator or coroutine object, with room for local stack and exception stack
7272
mp_obj_gen_instance_t *o = mp_obj_malloc_var(mp_obj_gen_instance_t, byte,
7373
n_state * sizeof(mp_obj_t) + n_exc_stack * sizeof(mp_exc_stack_t),
74-
self_fun->base.type == &mp_type_gen_wrap ? &mp_type_gen_instance : &mp_type_coro_instance);
74+
#if MICROPY_PY_ASYNC_AWAIT
75+
self_fun->base.type == &mp_type_gen_wrap ? &mp_type_gen_instance : &mp_type_coro_instance
76+
#else
77+
&mp_type_gen_instance
78+
#endif
79+
);
7580

7681
o->pend_exc = mp_const_none;
7782
o->code_state.fun_bc = self_fun;
@@ -198,8 +203,11 @@ mp_vm_return_kind_t mp_obj_gen_resume(mp_obj_t self_in, mp_obj_t send_value, mp_
198203
// note that self may have as its type either gen or coro,
199204
// both of which are stored as an mp_obj_gen_instance_t .
200205
mp_check_self(
201-
mp_obj_is_type(self_in, &mp_type_gen_instance) ||
202-
mp_obj_is_type(self_in, &mp_type_coro_instance));
206+
mp_obj_is_type(self_in, &mp_type_gen_instance)
207+
#if MICROPY_PY_ASYNC_AWAIT
208+
|| mp_obj_is_type(self_in, &mp_type_coro_instance)
209+
#endif
210+
);
203211
mp_obj_gen_instance_t *self = MP_OBJ_TO_PTR(self_in);
204212
if (self->code_state.ip == 0) {
205213
// Trying to resume an already stopped generator.

py/runtime.c

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1416,7 +1416,11 @@ mp_vm_return_kind_t mp_resume(mp_obj_t self_in, mp_obj_t send_value, mp_obj_t th
14161416
const mp_obj_type_t *type = mp_obj_get_type(self_in);
14171417

14181418
// CIRCUITPY distinguishes generators and coroutines.
1419-
if (type == &mp_type_gen_instance || type == &mp_type_coro_instance) {
1419+
if (type == &mp_type_gen_instance
1420+
#if MICROPY_PY_ASYNC_AWAIT
1421+
|| type == &mp_type_coro_instance
1422+
#endif
1423+
) {
14201424
return mp_obj_gen_resume(self_in, send_value, throw_value, ret_val);
14211425
}
14221426

0 commit comments

Comments
 (0)