aboutsummaryrefslogtreecommitdiff
path: root/tests
diff options
context:
space:
mode:
authorPaul Sokolovsky2015-05-11 02:59:25 +0300
committerDamien George2015-05-11 23:57:42 +0100
commit6738c1dded8e436686f85008ec0a4fc47406ab7a (patch)
treea2dadb126167355f5549dd7167da55b00268b822 /tests
parentd5e629ad0edf2c2b91f1964eb54c91fd6f6fc9d0 (diff)
vm: Properly handle StopIteration raised in user instance iterator.
I.e. in bytecode Python functions.
Diffstat (limited to 'tests')
-rw-r--r--tests/basics/gen_yield_from_ducktype.py22
1 files changed, 22 insertions, 0 deletions
diff --git a/tests/basics/gen_yield_from_ducktype.py b/tests/basics/gen_yield_from_ducktype.py
index aa0109c91..c02ec6756 100644
--- a/tests/basics/gen_yield_from_ducktype.py
+++ b/tests/basics/gen_yield_from_ducktype.py
@@ -42,3 +42,25 @@ g = gen3()
print(next(g))
print(g.send(5))
print(g.send(100))
+
+
+#
+# Test proper handling of StopIteration vs other exceptions
+#
+class MyIter:
+ def __iter__(self):
+ return self
+ def __next__(self):
+ raise StopIteration(42)
+
+def gen4():
+ global ret
+ ret = yield from MyIter()
+ 1//0
+
+ret = None
+try:
+ print(list(gen4()))
+except ZeroDivisionError:
+ print("ZeroDivisionError")
+print(ret)