Commit 3b1b45de authored by Stefan Behnel's avatar Stefan Behnel

Allow decorators on nested async-def functions.

Closes https://github.com/cython/cython/issues/1462
parent 7a974e4e
......@@ -23,6 +23,9 @@ Bugs fixed
* Complex buffer item types of structs of arrays could fail to validate.
Patch by Leo and smutch. (Github issue #1407)
* Decorators were not allowed on nested `async def` functions.
(Github issue #1462)
* C-tuples could use invalid C struct casting.
Patch by MegaIng. (Github issue #3038)
......
......@@ -2237,7 +2237,7 @@ def p_statement(s, ctx, first_statement = 0):
s.error('decorator not allowed here')
s.level = ctx.level
decorators = p_decorators(s)
if not ctx.allow_struct_enum_decorator and s.sy not in ('def', 'cdef', 'cpdef', 'class'):
if not ctx.allow_struct_enum_decorator and s.sy not in ('def', 'cdef', 'cpdef', 'class', 'async'):
if s.sy == 'IDENT' and s.systring == 'async':
pass # handled below
else:
......
......@@ -33,3 +33,30 @@ async def test_async_temp_gh3337(x, y):
([], 0)
"""
return min(x - y, 0)
async def outer_with_nested(called):
"""
>>> called = []
>>> _, inner = run_async(outer_with_nested(called))
>>> called # after outer_with_nested()
['outer', 'make inner', 'deco', 'return inner']
>>> _ = run_async(inner())
>>> called # after inner()
['outer', 'make inner', 'deco', 'return inner', 'inner']
"""
called.append('outer')
def deco(f):
called.append('deco')
return f
called.append('make inner')
@deco
async def inner():
called.append('inner')
return 1
called.append('return inner')
return inner
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