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
Boxiang Sun
cython
Commits
e2742e7b
Commit
e2742e7b
authored
Jul 06, 2018
by
scoder
Committed by
GitHub
Jul 06, 2018
Browse files
Options
Browse Files
Download
Plain Diff
Merge pull request #2453 from realead/error_for_cython_pyx
fixes #2422
parents
c94a9972
6c91bf8e
Changes
4
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
59 additions
and
2 deletions
+59
-2
Cython/Build/Dependencies.py
Cython/Build/Dependencies.py
+1
-2
Cython/Compiler/Main.py
Cython/Compiler/Main.py
+2
-0
Cython/Utils.py
Cython/Utils.py
+6
-0
tests/build/cythonize_cython.srctree
tests/build/cythonize_cython.srctree
+50
-0
No files found.
Cython/Build/Dependencies.py
View file @
e2742e7b
...
@@ -809,8 +809,7 @@ def create_extension_list(patterns, exclude=None, ctx=None, aliases=None, quiet=
...
@@ -809,8 +809,7 @@ def create_extension_list(patterns, exclude=None, ctx=None, aliases=None, quiet=
elif
name
:
elif
name
:
module_name
=
name
module_name
=
name
if
module_name
==
'cython'
:
Utils
.
raise_error_if_module_name_forbidden
(
module_name
)
raise
ValueError
(
'cython is a special module, cannot be used as a module name'
)
if
module_name
not
in
seen
:
if
module_name
not
in
seen
:
try
:
try
:
...
...
Cython/Compiler/Main.py
View file @
e2742e7b
...
@@ -469,6 +469,8 @@ def run_pipeline(source, options, full_module_name=None, context=None):
...
@@ -469,6 +469,8 @@ def run_pipeline(source, options, full_module_name=None, context=None):
abs_path
=
os
.
path
.
abspath
(
source
)
abs_path
=
os
.
path
.
abspath
(
source
)
full_module_name
=
full_module_name
or
context
.
extract_module_name
(
source
,
options
)
full_module_name
=
full_module_name
or
context
.
extract_module_name
(
source
,
options
)
Utils
.
raise_error_if_module_name_forbidden
(
full_module_name
)
if
options
.
relative_path_in_code_position_comments
:
if
options
.
relative_path_in_code_position_comments
:
rel_path
=
full_module_name
.
replace
(
'.'
,
os
.
sep
)
+
source_ext
rel_path
=
full_module_name
.
replace
(
'.'
,
os
.
sep
)
+
source_ext
if
not
abs_path
.
endswith
(
rel_path
):
if
not
abs_path
.
endswith
(
rel_path
):
...
...
Cython/Utils.py
View file @
e2742e7b
...
@@ -487,3 +487,9 @@ def add_metaclass(metaclass):
...
@@ -487,3 +487,9 @@ def add_metaclass(metaclass):
orig_vars
.
pop
(
'__weakref__'
,
None
)
orig_vars
.
pop
(
'__weakref__'
,
None
)
return
metaclass
(
cls
.
__name__
,
cls
.
__bases__
,
orig_vars
)
return
metaclass
(
cls
.
__name__
,
cls
.
__bases__
,
orig_vars
)
return
wrapper
return
wrapper
def
raise_error_if_module_name_forbidden
(
full_module_name
):
#it is bad idea to call the pyx-file cython.pyx, so fail early
if
full_module_name
==
'cython'
or
full_module_name
.
endswith
(
'.cython'
):
raise
ValueError
(
'cython is a special module, cannot be used as a module name'
)
tests/build/cythonize_cython.srctree
0 → 100644
View file @
e2742e7b
PYTHON -c "import cythonize_tests"
PYTHON -c "import cython_tests"
######## cythonize_tests.py ########
from Cython.Build.Cythonize import main as cythonize
for test_case in ["cython.pyx", "src/cython.pyx", "src2/cython.pyx"]:
try:
cythonize([test_case])
except ValueError:
pass
else:
assert False, "ValueError not raised - forbidding cythonize "+test_case+" doesn't work"
try:
cythonize(["notcython.pys"])
except ValueError:
assert False, "ValueError raised - forbidding cythonize notcython.pyx should work"
else:
pass
######## cython_tests.py ########
from Cython.Compiler.Main import main as cython
import sys
for test_case in ["cython.pyx", "src/cython.pyx", "src2/cython.pyx"]:
sys.argv=["cython", test_case] #cython.py will extract parameters from sys.argv
try:
cython(command_line=1)
except ValueError:
pass
else:
assert False, "ValueError not raised - forbidding cython "+test_case+" doesn't work"
sys.argv=["cython", "notcython.pyx"] #cython.py will extract parameters from sys.argv
try:
cython(["notcython.pys"])
except ValueError:
assert False, "ValueError raised - forbidding cythonize notcython.pyx should work"
else:
pass
######## cython.pyx ########
######## src/__init__.py ########
######## src/cython.pyx ########
######## notcython.pyx ########
######## src2/cython.pyx ########
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