@@ -73,6 +73,7 @@ void mp_emit_glue_assign_bytecode(mp_raw_code_t *rc, const byte *code,
7373 rc -> kind = MP_CODE_BYTECODE ;
7474 rc -> is_generator = (scope_flags & MP_SCOPE_FLAG_GENERATOR ) != 0 ;
7575 // CIRCUITPY-CHANGE: async and generator are distinguished
76+ // For async, BOTH is_generator and is_async will be set.
7677 rc -> is_async = (scope_flags & MP_SCOPE_FLAG_ASYNC ) != 0 ;
7778 rc -> fun_data = code ;
7879 rc -> children = children ;
@@ -137,6 +138,7 @@ void mp_emit_glue_assign_native(mp_raw_code_t *rc, mp_raw_code_kind_t kind, cons
137138 rc -> kind = kind ;
138139 rc -> is_generator = (scope_flags & MP_SCOPE_FLAG_GENERATOR ) != 0 ;
139140 // CIRCUITPY-CHANGE: async and generator are distinguished
141+ // For async, BOTH is_generator and is_async will be set.
140142 rc -> is_async = (scope_flags & MP_SCOPE_FLAG_ASYNC ) != 0 ;
141143 rc -> fun_data = fun_data ;
142144
@@ -219,6 +221,8 @@ mp_obj_t mp_make_function_from_proto_fun(mp_proto_fun_t proto_fun, const mp_modu
219221 // Check for a generator function, and if so change the type of the object
220222 // CIRCUITPY-CHANGE: distinguish generators and async
221223 #if MICROPY_PY_ASYNC_AWAIT
224+ // For async, BOTH is_async and is_generator will be set,
225+ // so check is_async first.
222226 if ((rc -> is_async ) != 0 ) {
223227 ((mp_obj_base_t * )MP_OBJ_TO_PTR (fun ))-> type = & mp_type_native_coro_wrap ;
224228 } else
@@ -242,8 +246,8 @@ mp_obj_t mp_make_function_from_proto_fun(mp_proto_fun_t proto_fun, const mp_modu
242246 fun = mp_obj_new_fun_bc (def_args , rc -> fun_data , context , rc -> children );
243247 // check for generator functions and if so change the type of the object
244248 // CIRCUITPY-CHANGE: distinguish generators and async
245- // A coroutine is MP_SCOPE_FLAG_ASYNC | MP_SCOPE_FLAG_GENERATOR ,
246- // so check for ASYNC first.
249+ // For async, BOTH is_async and is_generator will be set ,
250+ // so check is_async first.
247251 #if MICROPY_PY_ASYNC_AWAIT
248252 if ((rc -> is_async ) != 0 ) {
249253 ((mp_obj_base_t * )MP_OBJ_TO_PTR (fun ))-> type = & mp_type_coro_wrap ;
0 commit comments