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
7f9c0dca
Commit
7f9c0dca
authored
Aug 17, 2017
by
Stefan Behnel
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Provide a better error message when users accidentally write Cython code in a .py file.
Closes #1824.
parent
7e4f2ac0
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
16 additions
and
0 deletions
+16
-0
Cython/Compiler/Parsing.py
Cython/Compiler/Parsing.py
+7
-0
tests/errors/e_cdef_in_py.py
tests/errors/e_cdef_in_py.py
+9
-0
No files found.
Cython/Compiler/Parsing.py
View file @
7f9c0dca
...
...
@@ -2149,7 +2149,14 @@ def p_simple_statement_list(s, ctx, first_statement = 0):
stat
=
stats
[
0
]
else
:
stat
=
Nodes
.
StatListNode
(
pos
,
stats
=
stats
)
if
s
.
sy
not
in
(
'NEWLINE'
,
'EOF'
):
# provide a better error message for users who accidentally write Cython code in .py files
if
isinstance
(
stat
,
Nodes
.
ExprStatNode
):
if
stat
.
expr
.
is_name
and
stat
.
expr
.
name
==
'cdef'
:
s
.
error
(
"The 'cdef' keyword is only allowed in Cython files (pyx/pxi/pxd)"
,
pos
)
s
.
expect_newline
(
"Syntax error in simple statement list"
)
return
stat
def
p_compile_time_expr
(
s
):
...
...
tests/errors/e_cdef_in_py.py
0 → 100644
View file @
7f9c0dca
# mode: error
def
func
():
cdef
int
i
_ERRORS
=
"""
4:9: The 'cdef' keyword is only allowed in Cython files (pyx/pxi/pxd)
"""
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