diff options
author | Paul Sokolovsky <pfalcon@users.sourceforge.net> | 2015-05-11 02:59:25 +0300 |
---|---|---|
committer | Damien George <damien.p.george@gmail.com> | 2015-05-11 23:57:42 +0100 |
commit | 6738c1dded8e436686f85008ec0a4fc47406ab7a (patch) | |
tree | a2dadb126167355f5549dd7167da55b00268b822 /py | |
parent | d5e629ad0edf2c2b91f1964eb54c91fd6f6fc9d0 (diff) | |
download | micropython-6738c1dded8e436686f85008ec0a4fc47406ab7a.tar.gz micropython-6738c1dded8e436686f85008ec0a4fc47406ab7a.zip |
vm: Properly handle StopIteration raised in user instance iterator.
I.e. in bytecode Python functions.
Diffstat (limited to 'py')
-rw-r--r-- | py/vm.c | 6 |
1 files changed, 6 insertions, 0 deletions
@@ -1249,6 +1249,12 @@ exception_handler: code_state->ip = ip + ulab; // jump to after for-block code_state->sp -= 1; // pop the exhausted iterator goto outer_dispatch_loop; // continue with dispatch loop + } else if (*code_state->ip == MP_BC_YIELD_FROM) { + // StopIteration inside yield from call means return a value of + // yield from, so inject exception's value as yield from's result + *++code_state->sp = mp_obj_exception_get_value(nlr.ret_val); + code_state->ip++; // yield from is over, move to next instruction + goto outer_dispatch_loop; // continue with dispatch loop } } } |