Skip to content

Commit 2bce0bd

Browse files
committed
Merge branch 'master' of github.com:micropython/micropython
2 parents 0aa5d51 + 40d6d29 commit 2bce0bd

1 file changed

Lines changed: 7 additions & 4 deletions

File tree

py/vm.c

Lines changed: 7 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -391,6 +391,10 @@ mp_vm_return_kind_t mp_execute_byte_code_2(const byte *code_info, const byte **i
391391
break;
392392

393393
case MP_BC_WITH_CLEANUP: {
394+
// Arriving here, there's "exception control block" on top of stack,
395+
// and __exit__ bound method underneath it. Bytecode calls __exit__,
396+
// and "deletes" it off stack, shifting "exception control block"
397+
// to its place.
394398
static const mp_obj_t no_exc[] = {mp_const_none, mp_const_none, mp_const_none};
395399
if (TOP() == mp_const_none) {
396400
sp--;
@@ -432,8 +436,8 @@ mp_vm_return_kind_t mp_execute_byte_code_2(const byte *code_info, const byte **i
432436
//PUSH(MP_OBJ_NEW_SMALL_INT(UNWIND_SILENCED));
433437
// But what we need to do is - pop exception from value stack...
434438
sp -= 3;
435-
// ... pop with exception handler, and signal END_FINALLY
436-
// to just execute finally handler normally (signalled by None
439+
// ... pop "with" exception handler, and signal END_FINALLY
440+
// to just execute finally handler normally (by pushing None
437441
// on value stack)
438442
assert(exc_sp >= exc_stack);
439443
assert(exc_sp->opcode == MP_BC_SETUP_WITH);
@@ -709,8 +713,7 @@ mp_vm_return_kind_t mp_execute_byte_code_2(const byte *code_info, const byte **i
709713
*exc_sp_in_out = MP_TAGPTR_MAKE(exc_sp, currently_in_except_block);
710714
return MP_VM_RETURN_YIELD;
711715

712-
case MP_BC_YIELD_FROM:
713-
{
716+
case MP_BC_YIELD_FROM: {
714717
//#define EXC_MATCH(exc, type) MP_OBJ_IS_TYPE(exc, type)
715718
#define EXC_MATCH(exc, type) mp_obj_exception_match(exc, type)
716719
#define GENERATOR_EXIT_IF_NEEDED(t) if (t != MP_OBJ_NULL && EXC_MATCH(t, &mp_type_GeneratorExit)) { nlr_jump(t); }

0 commit comments

Comments
 (0)