Author: Raffael Tfirst <[email protected]>
Branch: py3.5-async
Changeset: r85913:0f9d6b6049cc
Date: 2016-07-29 18:49 +0200
http://bitbucket.org/pypy/pypy/changeset/0f9d6b6049cc/
Log: Add check in getAwaitableIter for Generator with ITERABLE_COROUTINE
flag, fix parameters, switch order of Coroutine and Generator check
in pyframe
diff --git a/pypy/interpreter/generator.py b/pypy/interpreter/generator.py
--- a/pypy/interpreter/generator.py
+++ b/pypy/interpreter/generator.py
@@ -2,6 +2,7 @@
from pypy.interpreter.error import OperationError, oefmt
from pypy.interpreter.pyopcode import LoopBlock
from pypy.interpreter.pycode import CO_YIELD_INSIDE_TRY
+from pypy.interpreter.astcompiler import consts
from rpython.rlib import jit
@@ -303,9 +304,13 @@
break
block = block.previous
- def _GetAwaitableIter(self, o):
+ def _GetAwaitableIter(self, space):
+ #check if coroutine
+ if w_iterable.pycode.co_flags & consts.CO_ITERABLE_COROUTINE:
+ return self
#look at typeobject.c, change to self.space.lookup(w_manager,
"__await__")
- return o
+ res = self.descr__await__(space)
+ return self
class Coroutine(W_Root):
@@ -324,7 +329,7 @@
# implement this function:
# https://github.com/python/cpython/blob/3.5/Objects/genobject.c#L786
# you need a new CoroutineWrapper object + CoroutineWrapperType
- pass
+ return self
def descr__reduce__(self, space):
from pypy.interpreter.mixedmodule import MixedModule
@@ -577,8 +582,8 @@
break
block = block.previous
- def _GetAwaitableIter(self, o):
- return o
+ def _GetAwaitableIter(self, space):
+ return self
diff --git a/pypy/interpreter/pyframe.py b/pypy/interpreter/pyframe.py
--- a/pypy/interpreter/pyframe.py
+++ b/pypy/interpreter/pyframe.py
@@ -240,12 +240,12 @@
def run(self):
"""Start this frame's execution."""
- if self.getcode().co_flags & pycode.CO_GENERATOR:
+ if self.getcode().co_flags & pycode.CO_COROUTINE:
+ from pypy.interpreter.generator import Coroutine
+ return self.space.wrap(Coroutine(self))
+ elif self.getcode().co_flags & pycode.CO_GENERATOR:
from pypy.interpreter.generator import GeneratorIterator
return self.space.wrap(GeneratorIterator(self))
- elif self.getcode().co_flags & pycode.CO_COROUTINE:
- from pypy.interpreter.generator import Coroutine
- return self.space.wrap(Coroutine(self))
else:
return self.execute_frame()
_______________________________________________
pypy-commit mailing list
[email protected]
https://mail.python.org/mailman/listinfo/pypy-commit