Skip to content
  • Damien George's avatar
    py/vm: Fix case of handling raised StopIteration within yield from. · 22ade2f5
    Damien George authored
    This patch concerns the handling of an NLR-raised StopIteration, raised
    during a call to mp_resume() which is handling the yield from opcode.
    
    Previously, commit 6738c1dd introduced code
    to handle this case, along with a test.  It seems that it was lucky that
    the test worked because the code did not correctly handle the stack pointer
    (sp).
    
    Furthermore, commit 79d996a5 improved the
    way mp_resume() propagated certain exceptions: it changed raising an NLR
    value to returning MP_VM_RETURN_EXCEPTION.  This change meant that the
    test introduced in gen_yield_from_ducktype.py was no longer hitting the
    code introduced in 6738c1dd.
    
    The patch here does two things:
    
    1. Fixes the handling of sp in the VM for the case that yield from is
       interrupted by a StopIteration raised via NLR.
    
    2. Introduces a new test to check this handling of sp and re-covers the
       code in the VM.
    22ade2f5