Commit d0d63887 authored by Stefan Behnel's avatar Stefan Behnel

Include required async utility code wherever it's used, not just by accident.

Closes #2075.
parent f9d11146
...@@ -4232,6 +4232,9 @@ class GeneratorBodyDefNode(DefNode): ...@@ -4232,6 +4232,9 @@ class GeneratorBodyDefNode(DefNode):
# on normal generator termination, we do not take the exception propagation # on normal generator termination, we do not take the exception propagation
# path: no traceback info is required and not creating it is much faster # path: no traceback info is required and not creating it is much faster
if not self.is_inlined and not self.body.is_terminator: if not self.is_inlined and not self.body.is_terminator:
if self.is_async_gen_body:
code.globalstate.use_utility_code(
UtilityCode.load_cached("StopAsyncIteration", "Coroutine.c"))
code.putln('PyErr_SetNone(%s);' % ( code.putln('PyErr_SetNone(%s);' % (
'__Pyx_PyExc_StopAsyncIteration' if self.is_async_gen_body else 'PyExc_StopIteration')) '__Pyx_PyExc_StopAsyncIteration' if self.is_async_gen_body else 'PyExc_StopIteration'))
# ----- Error cleanup # ----- Error cleanup
...@@ -5918,6 +5921,8 @@ class ReturnStatNode(StatNode): ...@@ -5918,6 +5921,8 @@ class ReturnStatNode(StatNode):
if self.return_type.is_pyobject: if self.return_type.is_pyobject:
if self.in_generator: if self.in_generator:
if self.in_async_gen: if self.in_async_gen:
code.globalstate.use_utility_code(
UtilityCode.load_cached("StopAsyncIteration", "Coroutine.c"))
code.put("PyErr_SetNone(__Pyx_PyExc_StopAsyncIteration); ") code.put("PyErr_SetNone(__Pyx_PyExc_StopAsyncIteration); ")
code.putln("%s = NULL;" % Naming.retval_cname) code.putln("%s = NULL;" % Naming.retval_cname)
else: else:
......
...@@ -102,6 +102,7 @@ static int __Pyx_async_gen_init_hooks(__pyx_PyAsyncGenObject *o) { ...@@ -102,6 +102,7 @@ static int __Pyx_async_gen_init_hooks(__pyx_PyAsyncGenObject *o) {
//////////////////// AsyncGenerator //////////////////// //////////////////// AsyncGenerator ////////////////////
//@requires: AsyncGeneratorInitFinalizer //@requires: AsyncGeneratorInitFinalizer
//@requires: Coroutine.c::Coroutine //@requires: Coroutine.c::Coroutine
//@requires: Coroutine.c::ReturnWithStopIteration
//@requires: ObjectHandling.c::PyObjectCallMethod1 //@requires: ObjectHandling.c::PyObjectCallMethod1
......
# Need to include all utility code !
async def sleep(x):
pass
async def call():
await sleep(1)
yield
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment