Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions mypyc/irbuild/statement.py
Original file line number Diff line number Diff line change
Expand Up @@ -712,6 +712,9 @@ def transform_try_except(
builder.builder.push_error_handler(double_except_block)
builder.activate_block(except_entry)
old_exc = builder.call_c(error_catch_op, [], line)
if builder.fn_info.is_generator:
# CFG cleanup may remove the CallC's block while resume cleanup paths remain.
old_exc = builder.ensure_register(old_exc)
# Compile the except blocks with the nonlocal control flow overridden to clear exc_info
builder.nonlocal_control.append(ExceptNonlocalControl(builder.nonlocal_control[-1], old_exc))

Expand Down
10 changes: 9 additions & 1 deletion mypyc/test-data/run-async.test
Original file line number Diff line number Diff line change
Expand Up @@ -292,8 +292,12 @@ async def async_with_vectorcall() -> str:
async with ctx:
return await async_val("vc")

async def async_with_pass() -> None:
async with async_ctx():
pass

[file driver.py]
from native import async_with, async_with_vectorcall
from native import async_with, async_with_pass, async_with_vectorcall
from testutil import run_generator

yields, val = run_generator(async_with(), [None, 'x', None])
Expand All @@ -304,6 +308,10 @@ yields, val = run_generator(async_with_vectorcall(), [None, 'x', None])
assert yields == ('enter', 'vc', 'exit'), yields
assert val == 'x', val

yields, val = run_generator(async_with_pass(), [None, None])
assert yields == ('enter', 'exit'), yields
assert val is None

[case testAsyncReturn]
from testutil import async_val

Expand Down
Loading