Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
C
cython
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
0
Merge Requests
0
Analytics
Analytics
Repository
Value Stream
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Commits
Issue Boards
Open sidebar
Kirill Smelkov
cython
Commits
3b1b45de
Commit
3b1b45de
authored
May 15, 2020
by
Stefan Behnel
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Allow decorators on nested async-def functions.
Closes
https://github.com/cython/cython/issues/1462
parent
7a974e4e
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
31 additions
and
1 deletion
+31
-1
CHANGES.rst
CHANGES.rst
+3
-0
Cython/Compiler/Parsing.py
Cython/Compiler/Parsing.py
+1
-1
tests/run/async_def.pyx
tests/run/async_def.pyx
+27
-0
No files found.
CHANGES.rst
View file @
3b1b45de
...
...
@@ -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
)
...
...
Cython/Compiler/Parsing.py
View file @
3b1b45de
...
...
@@ -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
:
...
...
tests/run/async_def.pyx
View file @
3b1b45de
...
...
@@ -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
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment