aboutsummaryrefslogtreecommitdiff
path: root/tests
diff options
context:
space:
mode:
authorDamien George2019-02-26 13:47:14 +1100
committerDamien George2019-02-26 23:52:10 +1100
commit12ce9f268909435b49f558d1d3c15ad7591d6fe8 (patch)
tree0e962e3d6d40eba1d34cdb7d6c88ea73ab1f6e02 /tests
parent823b31e5287ee96c96620dac81cfeafc889a69fd (diff)
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.
Diffstat (limited to 'tests')
-rw-r--r--tests/basics/async_with.py10
-rw-r--r--tests/basics/async_with.py.exp3
2 files changed, 13 insertions, 0 deletions
diff --git a/tests/basics/async_with.py b/tests/basics/async_with.py
index 5af0c5d95..f7774055c 100644
--- a/tests/basics/async_with.py
+++ b/tests/basics/async_with.py
@@ -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')
diff --git a/tests/basics/async_with.py.exp b/tests/basics/async_with.py.exp
index d00b18c96..6bbf84cb4 100644
--- a/tests/basics/async_with.py.exp
+++ b/tests/basics/async_with.py.exp
@@ -6,3 +6,6 @@ enter
1
exit <class 'ValueError'> error
ValueError
+enter
+exit <class 'BaseException'>
+BaseException