@@ -73,6 +73,7 @@ void mp_emit_glue_assign_bytecode(mp_raw_code_t *rc, const byte *code,
73
73
rc -> kind = MP_CODE_BYTECODE ;
74
74
rc -> is_generator = (scope_flags & MP_SCOPE_FLAG_GENERATOR ) != 0 ;
75
75
// CIRCUITPY-CHANGE: async and generator are distinguished
76
+ // For async, BOTH is_generator and is_async will be set.
76
77
rc -> is_async = (scope_flags & MP_SCOPE_FLAG_ASYNC ) != 0 ;
77
78
rc -> fun_data = code ;
78
79
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
137
138
rc -> kind = kind ;
138
139
rc -> is_generator = (scope_flags & MP_SCOPE_FLAG_GENERATOR ) != 0 ;
139
140
// CIRCUITPY-CHANGE: async and generator are distinguished
141
+ // For async, BOTH is_generator and is_async will be set.
140
142
rc -> is_async = (scope_flags & MP_SCOPE_FLAG_ASYNC ) != 0 ;
141
143
rc -> fun_data = fun_data ;
142
144
@@ -219,6 +221,8 @@ mp_obj_t mp_make_function_from_proto_fun(mp_proto_fun_t proto_fun, const mp_modu
219
221
// Check for a generator function, and if so change the type of the object
220
222
// CIRCUITPY-CHANGE: distinguish generators and async
221
223
#if MICROPY_PY_ASYNC_AWAIT
224
+ // For async, BOTH is_async and is_generator will be set,
225
+ // so check is_async first.
222
226
if ((rc -> is_async ) != 0 ) {
223
227
((mp_obj_base_t * )MP_OBJ_TO_PTR (fun ))-> type = & mp_type_native_coro_wrap ;
224
228
} else
@@ -242,8 +246,8 @@ mp_obj_t mp_make_function_from_proto_fun(mp_proto_fun_t proto_fun, const mp_modu
242
246
fun = mp_obj_new_fun_bc (def_args , rc -> fun_data , context , rc -> children );
243
247
// check for generator functions and if so change the type of the object
244
248
// 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.
247
251
#if MICROPY_PY_ASYNC_AWAIT
248
252
if ((rc -> is_async ) != 0 ) {
249
253
((mp_obj_base_t * )MP_OBJ_TO_PTR (fun ))-> type = & mp_type_coro_wrap ;
0 commit comments