summaryrefslogtreecommitdiff
path: root/Cython/Compiler/ParseTreeTransforms.py
diff options
context:
space:
mode:
authorStefan Behnel <stefan_ml@behnel.de>2018-02-28 21:18:56 +0100
committerStefan Behnel <stefan_ml@behnel.de>2018-02-28 21:18:56 +0100
commit108fe4c1488b38ce45a0d9651301694c82723bda (patch)
tree16e158238a31fa5fce4fd49a8f3cf3d08c7c0466 /Cython/Compiler/ParseTreeTransforms.py
parent857251b756ad7dbd4b3326f5d8a99f1c3cf329f4 (diff)
downloadcython-108fe4c1488b38ce45a0d9651301694c82723bda.tar.gz
Do not hijack "@asyncio.coroutine" to make async-def functions iterable, since this is really just a legacy feature that users should not overuse. Instead, provide a dedicated and explicit "cython.iterable_coroutine" directive.
Diffstat (limited to 'Cython/Compiler/ParseTreeTransforms.py')
-rw-r--r--Cython/Compiler/ParseTreeTransforms.py18
1 files changed, 2 insertions, 16 deletions
diff --git a/Cython/Compiler/ParseTreeTransforms.py b/Cython/Compiler/ParseTreeTransforms.py
index 7a70a7223..fb8eb07b0 100644
--- a/Cython/Compiler/ParseTreeTransforms.py
+++ b/Cython/Compiler/ParseTreeTransforms.py
@@ -2601,22 +2601,8 @@ class MarkClosureVisitor(CythonTransform):
coroutine_type = Nodes.AsyncGenNode
for yield_expr in collector.yields + collector.returns:
yield_expr.in_async_gen = True
- elif node.decorators:
- # evaluate @asyncio.coroutine() decorator at compile time if it's the inner-most one
- # TODO: better decorator validation: should come from imported module
- decorator = node.decorators[-1].decorator
- if decorator.is_name and decorator.name == 'coroutine':
- pass
- elif decorator.is_attribute and decorator.attribute == 'coroutine':
- if decorator.obj.is_name and decorator.obj.name in ('types', 'asyncio'):
- pass
- else:
- decorator = None
- else:
- decorator = None
- if decorator is not None:
- node.decorators.pop()
- coroutine_type = Nodes.IterableAsyncDefNode
+ elif self.current_directives['iterable_coroutine']:
+ coroutine_type = Nodes.IterableAsyncDefNode
elif collector.has_await:
found = next(y for y in collector.yields if y.is_await)
error(found.pos, "'await' not allowed in generators (use 'yield')")