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
d019d9f3
Commit
d019d9f3
authored
Jan 09, 2019
by
Jeroen Demeyer
Committed by
Stefan Behnel
Jun 29, 2019
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Correctly remove future_directives with # cython: language_level=2
parent
c7b13f37
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
18 additions
and
12 deletions
+18
-12
Cython/Compiler/Main.py
Cython/Compiler/Main.py
+5
-6
tests/run/language_level.srctree
tests/run/language_level.srctree
+13
-6
No files found.
Cython/Compiler/Main.py
View file @
d019d9f3
...
...
@@ -97,18 +97,17 @@ class Context(object):
def
set_language_level
(
self
,
level
):
from
.Future
import
print_function
,
unicode_literals
,
absolute_import
,
division
future_directives
=
[]
future_directives
=
set
()
if
level
==
'3str'
:
future_directives
=
[
print_function
,
absolute_import
,
division
]
self
.
future_directives
.
discard
(
unicode_literals
)
level
=
3
else
:
level
=
int
(
level
)
if
level
>=
3
:
future_directives
=
[
print_function
,
unicode_literals
,
absolute_import
,
division
]
future_directives
.
add
(
unicode_literals
)
if
level
>=
3
:
future_directives
.
update
([
print_function
,
absolute_import
,
division
])
self
.
language_level
=
level
if
future_directives
:
self
.
future_directives
.
update
(
future_directives
)
self
.
future_directives
=
future_directives
if
level
>=
3
:
self
.
modules
[
'builtins'
]
=
self
.
modules
[
'__builtin__'
]
...
...
tests/run/language_level.srctree
View file @
d019d9f3
...
...
@@ -7,12 +7,19 @@ PYTHON -c "import infile2; import infile3"
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})
)
)
ext_modules = []
# Test language_level specified in the cythonize() call
ext_modules += cythonize("directive2.py", compiler_directives={'language_level': 2})
ext_modules += cythonize("directive3.py", compiler_directives={'language_level': 3})
# Test language_level specified in the source file. We give a
# conflicting directive to cythonize() to check that the language_level
# is correctly overridden when compiling
ext_modules += cythonize("infile2.py", compiler_directives={'language_level': 3})
ext_modules += cythonize("infile3.py", compiler_directives={'language_level': 2})
setup(ext_modules=ext_modules)
######## directive3.py ########
...
...
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