mirror of
https://github.com/micropython/micropython.git
synced 2026-01-04 19:20:22 +01:00
py/vm: "yield from" didn't handle MP_OBJ_STOP_ITERATION optimization.
E.g. crashed when yielding from already stopped generators.
This commit is contained in:
3
py/vm.c
3
py/vm.c
@@ -1144,7 +1144,8 @@ yield:
|
||||
if (ret_kind == MP_VM_RETURN_NORMAL) {
|
||||
// Pop exhausted gen
|
||||
sp--;
|
||||
if (ret_value == MP_OBJ_NULL) {
|
||||
// TODO: When ret_value can be MP_OBJ_NULL here??
|
||||
if (ret_value == MP_OBJ_NULL || ret_value == MP_OBJ_STOP_ITERATION) {
|
||||
// Optimize StopIteration
|
||||
// TODO: get StopIteration's value
|
||||
PUSH(mp_const_none);
|
||||
|
||||
Reference in New Issue
Block a user