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
Gwenaël Samain
cython
Commits
bcdcd9fb
Commit
bcdcd9fb
authored
Aug 15, 2018
by
Stefan Behnel
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Improve error message for mixing return type declarations into def function syntax.
See #2529.
parent
7bebbddd
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
10 additions
and
1 deletion
+10
-1
Cython/Compiler/Parsing.py
Cython/Compiler/Parsing.py
+5
-1
tests/errors/invalid_syntax_py.pyx
tests/errors/invalid_syntax_py.pyx
+5
-0
No files found.
Cython/Compiler/Parsing.py
View file @
bcdcd9fb
...
...
@@ -3370,7 +3370,11 @@ def p_def_statement(s, decorators=None, is_async_def=False):
s
.
enter_async
()
s
.
next
()
name
=
_reject_cdef_modifier_in_py
(
s
,
p_ident
(
s
))
s
.
expect
(
'('
)
s
.
expect
(
'('
,
"Expected '(', found '%s'. Did you use cdef syntax in a Python declaration? "
"Use decorators and Python type annotations instead."
%
(
s
.
systring
if
s
.
sy
==
'IDENT'
else
s
.
sy
))
args
,
star_arg
,
starstar_arg
=
p_varargslist
(
s
,
terminator
=
')'
)
s
.
expect
(
')'
)
_reject_cdef_modifier_in_py
(
s
,
s
.
systring
)
...
...
tests/errors/invalid_syntax_py.pyx
View file @
bcdcd9fb
...
...
@@ -13,10 +13,15 @@ def nogil func() -> int:
def
func
()
nogil
:
pass
def
inline
int
*
func
():
pass
_ERRORS
=
u"""
4:11: Cannot use cdef modifier 'inline' in Python function signature. Use a decorator instead.
7:8: Cannot use cdef modifier 'api' in Python function signature. Use a decorator instead.
10:10: Cannot use cdef modifier 'nogil' in Python function signature. Use a decorator instead.
13:11: Cannot use cdef modifier 'nogil' in Python function signature. Use a decorator instead.
16:11: Cannot use cdef modifier 'inline' in Python function signature. Use a decorator instead.
16:14: Expected '(', found '*'. Did you use cdef syntax in a Python declaration? Use decorators and Python type annotations instead.
"""
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