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
d179a356
Commit
d179a356
authored
May 31, 2010
by
Stefan Behnel
Browse files
Options
Browse Files
Download
Plain Diff
merged in latest cython-devel
parents
90f8c776
d59f781c
Changes
9
Hide whitespace changes
Inline
Side-by-side
Showing
9 changed files
with
86 additions
and
6 deletions
+86
-6
Cython/Compiler/CmdLine.py
Cython/Compiler/CmdLine.py
+6
-0
Cython/Compiler/DebugFlags.py
Cython/Compiler/DebugFlags.py
+1
-1
Cython/Compiler/ExprNodes.py
Cython/Compiler/ExprNodes.py
+3
-2
Cython/Compiler/Main.py
Cython/Compiler/Main.py
+15
-2
Cython/Compiler/Options.py
Cython/Compiler/Options.py
+1
-0
Cython/Compiler/Parsing.py
Cython/Compiler/Parsing.py
+3
-0
runtests.py
runtests.py
+2
-1
tests/run/cython3.pyx
tests/run/cython3.pyx
+19
-0
tests/run/for_in_range_T372.pyx
tests/run/for_in_range_T372.pyx
+36
-0
No files found.
Cython/Compiler/CmdLine.py
View file @
d179a356
...
...
@@ -36,6 +36,8 @@ Options:
--line-directives Produce #line directives pointing to the .pyx source
--cplus Output a c++ rather than c file.
--embed Embed the Python interpreter in a main() method.
-2 Compile based on Python-2 syntax and code semantics.
-3 Compile based on Python-3 syntax and code semantics.
-X, --directive <name>=<value>[,<name=value,...] Overrides a compiler directive
"""
...
...
@@ -114,6 +116,10 @@ def parse_command_line(args):
Options
.
convert_range
=
True
elif
option
==
"--line-directives"
:
options
.
emit_linenums
=
True
elif
option
==
'-2'
:
options
.
language_level
=
2
elif
option
==
'-3'
:
options
.
language_level
=
3
elif
option
in
(
"-X"
,
"--directive"
):
try
:
options
.
compiler_directives
=
Options
.
parse_directive_list
(
...
...
Cython/Compiler/DebugFlags.py
View file @
d179a356
...
...
@@ -10,7 +10,7 @@ debug_temp_code_comments = 0
debug_trace_code_generation
=
0
# Do not replace exceptions with user-friendly error messages
debug_no_exception_intercept
=
1
debug_no_exception_intercept
=
0
# Print a message each time a new stage in the pipeline is entered
debug_verbose_pipeline
=
0
Cython/Compiler/ExprNodes.py
View file @
d179a356
...
...
@@ -804,8 +804,9 @@ class IntNode(ConstNode):
if
self
.
type
is
dst_type
:
return
self
elif
dst_type
.
is_float
:
return
FloatNode
(
self
.
pos
,
value
=
repr
(
float
(
self
.
value
)))
node
=
IntNode
(
self
.
pos
,
value
=
self
.
value
,
float_value
=
float
(
self
.
value
)
return
FloatNode
(
self
.
pos
,
value
=
repr
(
float_value
),
constant_result
=
float_value
)
node
=
IntNode
(
self
.
pos
,
value
=
self
.
value
,
constant_result
=
self
.
constant_result
,
unsigned
=
self
.
unsigned
,
longness
=
self
.
longness
)
if
dst_type
.
is_numeric
and
not
dst_type
.
is_complex
:
return
node
...
...
Cython/Compiler/Main.py
View file @
d179a356
...
...
@@ -65,8 +65,9 @@ class Context(object):
# modules {string : ModuleScope}
# include_directories [string]
# future_directives [object]
# language_level int currently 2 or 3 for Python 2/3
def
__init__
(
self
,
include_directories
,
compiler_directives
,
cpp
=
False
):
def
__init__
(
self
,
include_directories
,
compiler_directives
,
cpp
=
False
,
language_level
=
2
):
#self.modules = {"__builtin__" : BuiltinScope()}
import
Builtin
,
CythonScope
self
.
modules
=
{
"__builtin__"
:
Builtin
.
builtin_scope
}
...
...
@@ -82,6 +83,15 @@ class Context(object):
os
.
path
.
join
(
os
.
path
.
dirname
(
__file__
),
os
.
path
.
pardir
,
'Includes'
)))
self
.
include_directories
=
include_directories
+
[
standard_include_path
]
self
.
set_language_level
(
language_level
)
def
set_language_level
(
self
,
level
):
self
.
language_level
=
level
if
level
>=
3
:
from
Future
import
print_function
,
unicode_literals
self
.
future_directives
.
add
(
print_function
)
self
.
future_directives
.
add
(
unicode_literals
)
def
create_pipeline
(
self
,
pxd
,
py
=
False
):
from
Visitor
import
PrintTree
from
ParseTreeTransforms
import
WithTransform
,
NormalizeTree
,
PostParse
,
PxdPostParse
...
...
@@ -543,7 +553,8 @@ def create_default_resultobj(compilation_source, options):
def
run_pipeline
(
source
,
options
,
full_module_name
=
None
):
# Set up context
context
=
Context
(
options
.
include_path
,
options
.
compiler_directives
,
options
.
cplus
)
context
=
Context
(
options
.
include_path
,
options
.
compiler_directives
,
options
.
cplus
,
options
.
language_level
)
# Set up source object
cwd
=
os
.
getcwd
()
...
...
@@ -598,6 +609,7 @@ class CompilationOptions(object):
quiet boolean Don't print source names in recursive mode
compiler_directives dict Overrides for pragma options (see Options.py)
evaluate_tree_assertions boolean Test support: evaluate parse tree assertions
language_level integer The Python language level: 2 or 3
cplus boolean Compile as c++ code
"""
...
...
@@ -776,4 +788,5 @@ default_options = dict(
compiler_directives
=
{},
evaluate_tree_assertions
=
False
,
emit_linenums
=
False
,
language_level
=
2
,
)
Cython/Compiler/Options.py
View file @
d179a356
...
...
@@ -66,6 +66,7 @@ directive_defaults = {
'infer_types'
:
None
,
'infer_types.verbose'
:
False
,
'autotestdict'
:
True
,
'language_level'
:
2
,
'warn'
:
None
,
'warn.undeclared'
:
False
,
...
...
Cython/Compiler/Parsing.py
View file @
d179a356
...
...
@@ -2706,6 +2706,9 @@ def p_module(s, pxd, full_module_name):
directive_comments = p_compiler_directive_comments(s)
s.parse_comments = False
if 'language_level' in directive_comments:
s.context.set_language_level('language_level')
doc = p_doc_string(s)
if pxd:
level = 'module_pxd'
...
...
runtests.py
View file @
d179a356
...
...
@@ -56,7 +56,8 @@ VER_DEP_MODULES = {
]),
(2,4) : (operator.le, lambda x: x in ['
run
.
extern_builtins_T258
'
]),
(2,6) : (operator.lt, lambda x: x in ['
run
.
print_function
'
(2,6) : (operator.lt, lambda x: x in ['
run
.
print_function
',
'
run
.
cython3
',
]),
(3,): (operator.ge, lambda x: x in ['
run
.
non_future_division
',
'
compile
.
extsetslice
',
...
...
tests/run/cython3.pyx
0 → 100644
View file @
d179a356
# cython: language_level=3
def
print_function
(
*
args
):
"""
>>> print_function(1,2,3)
1 2 3
"""
print
(
*
args
)
# this isn't valid Py2 syntax
ustring
=
"abcdefg"
def
unicode_literals
():
"""
>>> print( unicode_literals() )
True
abcdefg
"""
print
(
isinstance
(
ustring
,
unicode
)
or
type
(
ustring
))
return
ustring
tests/run/for_in_range_T372.pyx
View file @
d179a356
...
...
@@ -20,6 +20,42 @@ def test_modify():
print
return
i
,
n
@
cython
.
test_assert_path_exists
(
"//ForFromStatNode"
)
@
cython
.
test_fail_if_path_exists
(
"//ForInStatNode"
)
def
test_negindex
():
"""
>>> test_negindex()
6
5
4
3
2
(2, 0)
"""
cdef
int
i
,
n
=
5
for
i
in
range
(
n
+
1
,
1
,
-
1
):
print
i
n
=
0
return
i
,
n
@
cython
.
test_assert_path_exists
(
"//ForFromStatNode"
,
"//ForFromStatNode//PrintStatNode//CoerceToPyTypeNode"
)
@
cython
.
test_fail_if_path_exists
(
"//ForInStatNode"
)
def
test_negindex_inferred
():
"""
>>> test_negindex_inferred()
5
4
3
2
(2, 0)
"""
cdef
int
n
=
5
for
i
in
range
(
n
,
1
,
-
1
):
print
i
n
=
0
return
i
,
n
@
cython
.
test_assert_path_exists
(
"//ForFromStatNode"
)
@
cython
.
test_fail_if_path_exists
(
"//ForInStatNode"
)
def
test_fix
():
...
...
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