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
cf5b4acb
Commit
cf5b4acb
authored
Jul 15, 2018
by
Egor Dranischnikow
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
fail early if module is called cython (and not submodule)
parent
3f7a0302
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
26 additions
and
18 deletions
+26
-18
Cython/Utils.py
Cython/Utils.py
+1
-1
tests/build/cythonize_cython.srctree
tests/build/cythonize_cython.srctree
+25
-17
No files found.
Cython/Utils.py
View file @
cf5b4acb
...
...
@@ -491,5 +491,5 @@ def add_metaclass(metaclass):
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
'
):
if
full_module_name
==
'cython'
or
full_module_name
.
startswith
(
'cython.
'
):
raise
ValueError
(
'cython is a special module, cannot be used as a module name'
)
tests/build/cythonize_cython.srctree
View file @
cf5b4acb
...
...
@@ -5,7 +5,7 @@ PYTHON -c "import cython_tests"
from Cython.Build.Cythonize import main as cythonize
for test_case in ["cython.pyx", "src
/cython.pyx", "src2/cython
.pyx"]:
for test_case in ["cython.pyx", "src
2/cython.pyx", "src/cython/helper
.pyx"]:
try:
cythonize([test_case])
except ValueError:
...
...
@@ -13,12 +13,13 @@ for test_case in ["cython.pyx", "src/cython.pyx", "src2/cython.pyx"]:
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
for test_case in ["notcython.pyx", "my_module/cython.pyx", "cythontest/helper.pyx"]:
try:
cythonize([test_case])
except ValueError:
assert False, "ValueError raised - cythonize "+test_case+" should work"
else:
pass
######## cython_tests.py ########
...
...
@@ -26,7 +27,7 @@ else:
from Cython.Compiler.Main import main as cython
import sys
for test_case in ["cython.pyx", "s
rc/cython.pyx", "src2/cython
.pyx"]:
for test_case in ["cython.pyx", "s
cr2/cython.pyx", "src/cython/helper
.pyx"]:
sys.argv=["cython", test_case] #cython.py will extract parameters from sys.argv
try:
cython(command_line=1)
...
...
@@ -35,16 +36,23 @@ for test_case in ["cython.pyx", "src/cython.pyx", "src2/cython.pyx"]:
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
for test_case in ["notcython.pyx", "my_module/cython.pyx", "cythontest/helper.pyx"]:
sys.argv=["cython", test_case] #cython.py will extract parameters from sys.argv
try:
cython([test_case])
except ValueError:
assert False, "ValueError raised - cython "+test_case+" should work"
else:
pass
######## cython.pyx ########
########
src
/__init__.py ########
########
src
/cython.pyx ########
########
my_module
/__init__.py ########
########
my_module
/cython.pyx ########
######## notcython.pyx ########
######## src2/cython.pyx ########
######## src/cython/__init__.py ########
######## src/cython/helper.pyx ########
######## cythontest/__init__.py ########
######## cythontest/helper.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