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
c5be029b
Commit
c5be029b
authored
Aug 16, 2012
by
Stefan Behnel
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
fix for passing language_level externally as compiler directive
parent
f58ddd33
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
40 additions
and
0 deletions
+40
-0
Cython/Compiler/Main.py
Cython/Compiler/Main.py
+2
-0
runtests.py
runtests.py
+1
-0
tests/run/language_level.srctree
tests/run/language_level.srctree
+37
-0
No files found.
Cython/Compiler/Main.py
View file @
c5be029b
...
...
@@ -473,6 +473,8 @@ class CompilationOptions(object):
defaults
=
default_options
self
.
__dict__
.
update
(
defaults
)
self
.
__dict__
.
update
(
kw
)
if
'language_level'
not
in
kw
and
'language_level'
in
self
.
compiler_directives
:
self
.
language_level
=
int
(
self
.
compiler_directives
[
'language_level'
])
def
create_context
(
self
):
return
Context
(
self
.
include_path
,
self
.
compiler_directives
,
...
...
runtests.py
View file @
c5be029b
...
...
@@ -183,6 +183,7 @@ VER_DEP_MODULES = {
'run.initial_file_path', # relative import
]),
(2,6) : (operator.lt, lambda x: x in ['run.print_function',
'run.language_level', # print function
'run.cython3',
'run.property_decorator_T593', # prop.setter etc.
'run.generators_py', # generators, with statement
...
...
tests/run/language_level.srctree
0 → 100644
View file @
c5be029b
PYTHON setup.py build_ext --inplace
PYTHON -c "import directive2; import directive3"
PYTHON -c "import infile2; import infile3"
######## setup.py ########
from Cython.Build.Dependencies import cythonize
from distutils.core import setup
setup(
ext_modules = (cythonize("infile*.py") +
cythonize("directive2.py", compiler_directives={'language_level': 2}) +
cythonize("directive3.py", compiler_directives={'language_level': 3})
)
)
######## directive3.py ########
import sys
print("SUCCESS", file=sys.stdout)
######## directive2.py ########
print "SUCCESS"
######## infile3.py ########
# cython: language_level=3
import sys
print("SUCCESS", file=sys.stdout)
######## infile2.py ########
# cython: language_level=2
print "SUCCESS"
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