extended test case: coroutine.throw() while handling an exception already
authorStefan Behnel <scoder@users.berlios.de>
Thu, 28 Apr 2011 20:11:25 +0000 (22:11 +0200)
committerStefan Behnel <scoder@users.berlios.de>
Thu, 28 Apr 2011 20:11:25 +0000 (22:11 +0200)
tests/run/generators_py.py

index 57a11d0a9cccf553e310d176a933690a54c0a09c..b43962cd17c0d60c946b405547143de4ad34c78d 100644 (file)
@@ -167,6 +167,40 @@ def check_yield_in_except():
     except ValueError:
         yield
 
+def yield_in_except_throw_exc_type():
+    """
+    >>> import sys
+    >>> g = yield_in_except_throw_exc_type()
+    >>> next(g)
+    >>> g.throw(TypeError)
+    Traceback (most recent call last):
+    TypeError
+    >>> next(g)
+    Traceback (most recent call last):
+    StopIteration
+    """
+    try:
+        raise ValueError
+    except ValueError:
+        yield
+
+def yield_in_except_throw_instance():
+    """
+    >>> import sys
+    >>> g = yield_in_except_throw_instance()
+    >>> next(g)
+    >>> g.throw(TypeError())
+    Traceback (most recent call last):
+    TypeError
+    >>> next(g)
+    Traceback (most recent call last):
+    StopIteration
+    """
+    try:
+        raise ValueError
+    except ValueError:
+        yield
+
 def test_swap_assignment():
     """
     >>> gen = test_swap_assignment()