Author: Armin Rigo <[email protected]>
Branch: py3.5-corowrapper
Changeset: r87112:4f2a6936d18e
Date: 2016-09-14 18:26 +0200
http://bitbucket.org/pypy/pypy/changeset/4f2a6936d18e/
Log: First test: space.next() must not accept coroutines (and not by
*name* anyway!)
diff --git a/pypy/interpreter/test/test_coroutine.py
b/pypy/interpreter/test/test_coroutine.py
new file mode 100644
--- /dev/null
+++ b/pypy/interpreter/test/test_coroutine.py
@@ -0,0 +1,10 @@
+
+class AppTestCoroutine:
+
+ def test_cannot_iterate(self): """
+ async def f(x):
+ pass
+ raises(TypeError, "for i in f(5): pass")
+ raises(TypeError, iter, f(5))
+ raises(TypeError, next, f(5))
+ """
diff --git a/pypy/objspace/descroperation.py b/pypy/objspace/descroperation.py
--- a/pypy/objspace/descroperation.py
+++ b/pypy/objspace/descroperation.py
@@ -298,10 +298,7 @@
return w_iter
def next(space, w_obj):
- if space.type(w_obj).name == 'coroutine':
- w_descr = space.lookup(w_obj, '__anext__')
- else:
- w_descr = space.lookup(w_obj, '__next__')
+ w_descr = space.lookup(w_obj, '__next__')
if w_descr is None:
raise oefmt(space.w_TypeError,
"'%T' object is not an iterator", w_obj)
_______________________________________________
pypy-commit mailing list
[email protected]
https://mail.python.org/mailman/listinfo/pypy-commit