Author: Manuel Jacob <m...@manueljacob.de>
Branch: py3.6
Changeset: r91921:3de6fb333784
Date: 2017-07-19 00:21 +0200
http://bitbucket.org/pypy/pypy/changeset/3de6fb333784/

Log:    Implement AsyncGenABase.descr_close(). Translation should work
        again!

diff --git a/pypy/interpreter/generator.py b/pypy/interpreter/generator.py
--- a/pypy/interpreter/generator.py
+++ b/pypy/interpreter/generator.py
@@ -642,7 +642,7 @@
             raise
 
     def descr_close(self):
-        XXX
+        self.state = self.ST_CLOSED
 
     def unwrap_value(self, w_value):
         if isinstance(w_value, AsyncGenValueWrapper):
diff --git a/pypy/interpreter/test/test_coroutine.py 
b/pypy/interpreter/test/test_coroutine.py
--- a/pypy/interpreter/test/test_coroutine.py
+++ b/pypy/interpreter/test/test_coroutine.py
@@ -485,3 +485,17 @@
             await a.aclose()
         raises(RuntimeError, run().send, None)
     """
+
+    def test_async_anext_close(self): """
+        async def ag():
+            yield 42
+
+        an = ag().__anext__()
+        an.close()
+        try:
+            next(an)
+        except StopIteration as e:
+            assert e.value is None
+        else:
+            assert False, "didn't raise"
+    """
_______________________________________________
pypy-commit mailing list
pypy-commit@python.org
https://mail.python.org/mailman/listinfo/pypy-commit

Reply via email to