py/compile: Fix handling of unwinding BaseException in async with.

All exceptions that unwind through the async-with must be caught and
BaseException is the top-level class, which includes Exception and others.

Fixes issue #4552.
This commit is contained in:
Damien George
2019-02-26 13:47:14 +11:00
parent 823b31e528
commit 12ce9f2689
3 changed files with 14 additions and 1 deletions

View File

@@ -27,3 +27,13 @@ try:
o.send(None)
except ValueError:
print('ValueError')
# test raising BaseException to make sure it is handled by the async-with
async def h():
async with AContext():
raise BaseException
o = h()
try:
o.send(None)
except BaseException:
print('BaseException')