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
9498ab65
Commit
9498ab65
authored
9 years ago
by
Stefan Behnel
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
replace xrange() by range() to make it work in Py2/Py3
parent
9c7d4b13
Changes
9
Hide whitespace changes
Inline
Side-by-side
Showing
9 changed files
with
20 additions
and
24 deletions
+20
-24
Cython/Compiler/ExprNodes.py
Cython/Compiler/ExprNodes.py
+6
-6
Cython/Compiler/MemoryView.py
Cython/Compiler/MemoryView.py
+1
-1
Cython/Compiler/Nodes.py
Cython/Compiler/Nodes.py
+2
-2
Cython/Compiler/ParseTreeTransforms.py
Cython/Compiler/ParseTreeTransforms.py
+3
-3
Cython/Compiler/Parsing.py
Cython/Compiler/Parsing.py
+2
-2
Cython/Compiler/TypeSlots.py
Cython/Compiler/TypeSlots.py
+1
-1
Cython/Debugger/libpython.py
Cython/Debugger/libpython.py
+1
-1
Cython/Plex/Regexps.py
Cython/Plex/Regexps.py
+3
-7
Cython/Plex/Traditional.py
Cython/Plex/Traditional.py
+1
-1
No files found.
Cython/Compiler/ExprNodes.py
View file @
9498ab65
...
@@ -4769,7 +4769,7 @@ class SimpleCallNode(CallNode):
...
@@ -4769,7 +4769,7 @@ class SimpleCallNode(CallNode):
# Coerce arguments
# Coerce arguments
some_args_in_temps
=
False
some_args_in_temps
=
False
for
i
in
x
range
(
min
(
max_nargs
,
actual_nargs
)):
for
i
in
range
(
min
(
max_nargs
,
actual_nargs
)):
formal_arg
=
func_type
.
args
[
i
]
formal_arg
=
func_type
.
args
[
i
]
formal_type
=
formal_arg
.
type
formal_type
=
formal_arg
.
type
arg
=
args
[
i
].
coerce_to
(
formal_type
,
env
)
arg
=
args
[
i
].
coerce_to
(
formal_type
,
env
)
...
@@ -4799,7 +4799,7 @@ class SimpleCallNode(CallNode):
...
@@ -4799,7 +4799,7 @@ class SimpleCallNode(CallNode):
args
[
i
]
=
arg
args
[
i
]
=
arg
# handle additional varargs parameters
# handle additional varargs parameters
for
i
in
x
range
(
max_nargs
,
actual_nargs
):
for
i
in
range
(
max_nargs
,
actual_nargs
):
arg
=
args
[
i
]
arg
=
args
[
i
]
if
arg
.
type
.
is_pyobject
:
if
arg
.
type
.
is_pyobject
:
arg_ctype
=
arg
.
type
.
default_coerced_ctype
()
arg_ctype
=
arg
.
type
.
default_coerced_ctype
()
...
@@ -4817,7 +4817,7 @@ class SimpleCallNode(CallNode):
...
@@ -4817,7 +4817,7 @@ class SimpleCallNode(CallNode):
# sure they are either all temps or all not temps (except
# sure they are either all temps or all not temps (except
# for the last argument, which is evaluated last in any
# for the last argument, which is evaluated last in any
# case)
# case)
for
i
in
x
range
(
actual_nargs
-
1
):
for
i
in
range
(
actual_nargs
-
1
):
if
i
==
0
and
self
.
self
is
not
None
:
if
i
==
0
and
self
.
self
is
not
None
:
continue
# self is ok
continue
# self is ok
arg
=
args
[
i
]
arg
=
args
[
i
]
...
@@ -5207,7 +5207,7 @@ class InlinedDefNodeCallNode(CallNode):
...
@@ -5207,7 +5207,7 @@ class InlinedDefNodeCallNode(CallNode):
# Coerce arguments
# Coerce arguments
some_args_in_temps
=
False
some_args_in_temps
=
False
for
i
in
x
range
(
actual_nargs
):
for
i
in
range
(
actual_nargs
):
formal_type
=
func_type
.
args
[
i
].
type
formal_type
=
func_type
.
args
[
i
].
type
arg
=
self
.
args
[
i
].
coerce_to
(
formal_type
,
env
)
arg
=
self
.
args
[
i
].
coerce_to
(
formal_type
,
env
)
if
arg
.
is_temp
:
if
arg
.
is_temp
:
...
@@ -5234,7 +5234,7 @@ class InlinedDefNodeCallNode(CallNode):
...
@@ -5234,7 +5234,7 @@ class InlinedDefNodeCallNode(CallNode):
# sure they are either all temps or all not temps (except
# sure they are either all temps or all not temps (except
# for the last argument, which is evaluated last in any
# for the last argument, which is evaluated last in any
# case)
# case)
for
i
in
x
range
(
actual_nargs
-
1
):
for
i
in
range
(
actual_nargs
-
1
):
arg
=
self
.
args
[
i
]
arg
=
self
.
args
[
i
]
if
arg
.
nonlocally_immutable
():
if
arg
.
nonlocally_immutable
():
# locals, C functions, unassignable types are safe.
# locals, C functions, unassignable types are safe.
...
@@ -6503,7 +6503,7 @@ class SequenceNode(ExprNode):
...
@@ -6503,7 +6503,7 @@ class SequenceNode(ExprNode):
else
:
else
:
offset
=
''
offset
=
''
for
i
in
x
range
(
arg_count
):
for
i
in
range
(
arg_count
):
arg
=
self
.
args
[
i
]
arg
=
self
.
args
[
i
]
if
c_mult
or
not
arg
.
result_in_temp
():
if
c_mult
or
not
arg
.
result_in_temp
():
code
.
put_incref
(
arg
.
result
(),
arg
.
ctype
())
code
.
put_incref
(
arg
.
result
(),
arg
.
ctype
())
...
...
This diff is collapsed.
Click to expand it.
Cython/Compiler/MemoryView.py
View file @
9498ab65
...
@@ -790,7 +790,7 @@ def validate_axes_specs(positions, specs, is_c_contig, is_f_contig):
...
@@ -790,7 +790,7 @@ def validate_axes_specs(positions, specs, is_c_contig, is_f_contig):
if
access
==
'ptr'
:
if
access
==
'ptr'
:
last_indirect_dimension
=
idx
last_indirect_dimension
=
idx
for
idx
,
pos
,
(
access
,
packing
)
in
zip
(
x
range
(
len
(
specs
)),
positions
,
specs
):
for
idx
,
pos
,
(
access
,
packing
)
in
zip
(
range
(
len
(
specs
)),
positions
,
specs
):
if
not
(
access
in
access_specs
and
if
not
(
access
in
access_specs
and
packing
in
packing_specs
):
packing
in
packing_specs
):
...
...
This diff is collapsed.
Click to expand it.
Cython/Compiler/Nodes.py
View file @
9498ab65
...
@@ -6684,7 +6684,7 @@ class TryExceptStatNode(StatNode):
...
@@ -6684,7 +6684,7 @@ class TryExceptStatNode(StatNode):
try_end_label
=
code
.
new_label
(
'try_end'
)
try_end_label
=
code
.
new_label
(
'try_end'
)
exc_save_vars
=
[
code
.
funcstate
.
allocate_temp
(
py_object_type
,
False
)
exc_save_vars
=
[
code
.
funcstate
.
allocate_temp
(
py_object_type
,
False
)
for
_
in
x
range
(
3
)]
for
_
in
range
(
3
)]
code
.
mark_pos
(
self
.
pos
)
code
.
mark_pos
(
self
.
pos
)
code
.
putln
(
"{"
)
code
.
putln
(
"{"
)
save_exc
=
code
.
insertion_point
()
save_exc
=
code
.
insertion_point
()
...
@@ -6869,7 +6869,7 @@ class ExceptClauseNode(Node):
...
@@ -6869,7 +6869,7 @@ class ExceptClauseNode(Node):
exc_vars
=
[
code
.
funcstate
.
allocate_temp
(
py_object_type
,
exc_vars
=
[
code
.
funcstate
.
allocate_temp
(
py_object_type
,
manage_ref
=
True
)
manage_ref
=
True
)
for
_
in
x
range
(
3
)]
for
_
in
range
(
3
)]
code
.
put_add_traceback
(
self
.
function_name
)
code
.
put_add_traceback
(
self
.
function_name
)
# We always have to fetch the exception value even if
# We always have to fetch the exception value even if
# there is no target, because this also normalises the
# there is no target, because this also normalises the
...
...
This diff is collapsed.
Click to expand it.
Cython/Compiler/ParseTreeTransforms.py
View file @
9498ab65
...
@@ -420,11 +420,11 @@ def sort_common_subsequences(items):
...
@@ -420,11 +420,11 @@ def sort_common_subsequences(items):
for
pos
,
item
in
enumerate
(
items
):
for
pos
,
item
in
enumerate
(
items
):
key
=
item
[
1
]
# the ResultRefNode which has already been injected into the sequences
key
=
item
[
1
]
# the ResultRefNode which has already been injected into the sequences
new_pos
=
pos
new_pos
=
pos
for
i
in
x
range
(
pos
-
1
,
-
1
,
-
1
):
for
i
in
range
(
pos
-
1
,
-
1
,
-
1
):
if
lower_than
(
key
,
items
[
i
][
0
]):
if
lower_than
(
key
,
items
[
i
][
0
]):
new_pos
=
i
new_pos
=
i
if
new_pos
!=
pos
:
if
new_pos
!=
pos
:
for
i
in
x
range
(
pos
,
new_pos
,
-
1
):
for
i
in
range
(
pos
,
new_pos
,
-
1
):
items
[
i
]
=
items
[
i
-
1
]
items
[
i
]
=
items
[
i
-
1
]
items
[
new_pos
]
=
item
items
[
new_pos
]
=
item
...
@@ -460,7 +460,7 @@ def flatten_parallel_assignments(input, output):
...
@@ -460,7 +460,7 @@ def flatten_parallel_assignments(input, output):
rhs_args
=
unpack_string_to_character_literals
(
rhs
)
rhs_args
=
unpack_string_to_character_literals
(
rhs
)
rhs_size
=
len
(
rhs_args
)
rhs_size
=
len
(
rhs_args
)
lhs_targets
=
[
[]
for
_
in
xrange
(
rhs_size
)
]
lhs_targets
=
[
[]
for
_
in
range
(
rhs_size
)
]
starred_assignments
=
[]
starred_assignments
=
[]
for
lhs
in
input
[:
-
1
]:
for
lhs
in
input
[:
-
1
]:
if
not
lhs
.
is_sequence_constructor
:
if
not
lhs
.
is_sequence_constructor
:
...
...
This diff is collapsed.
Click to expand it.
Cython/Compiler/Parsing.py
View file @
9498ab65
...
@@ -3450,7 +3450,7 @@ def print_parse_tree(f, node, level, key = None):
...
@@ -3450,7 +3450,7 @@ def print_parse_tree(f, node, level, key = None):
t
=
type
(
node
)
t
=
type
(
node
)
if
t
is
tuple
:
if
t
is
tuple
:
f
.
write
(
"(%s @ %s
\
n
"
%
(
node
[
0
],
node
[
1
]))
f
.
write
(
"(%s @ %s
\
n
"
%
(
node
[
0
],
node
[
1
]))
for
i
in
x
range
(
2
,
len
(
node
)):
for
i
in
range
(
2
,
len
(
node
)):
print_parse_tree
(
f
,
node
[
i
],
level
+
1
)
print_parse_tree
(
f
,
node
[
i
],
level
+
1
)
f
.
write
(
"%s)
\
n
"
%
ind
)
f
.
write
(
"%s)
\
n
"
%
ind
)
return
return
...
@@ -3466,7 +3466,7 @@ def print_parse_tree(f, node, level, key = None):
...
@@ -3466,7 +3466,7 @@ def print_parse_tree(f, node, level, key = None):
return
return
elif
t
is
list
:
elif
t
is
list
:
f
.
write
(
"[
\
n
"
)
f
.
write
(
"[
\
n
"
)
for
i
in
x
range
(
len
(
node
)):
for
i
in
range
(
len
(
node
)):
print_parse_tree
(
f
,
node
[
i
],
level
+
1
)
print_parse_tree
(
f
,
node
[
i
],
level
+
1
)
f
.
write
(
"%s]
\
n
"
%
ind
)
f
.
write
(
"%s]
\
n
"
%
ind
)
return
return
...
...
This diff is collapsed.
Click to expand it.
Cython/Compiler/TypeSlots.py
View file @
9498ab65
...
@@ -127,7 +127,7 @@ class Signature(object):
...
@@ -127,7 +127,7 @@ class Signature(object):
def
function_type
(
self
,
self_arg_override
=
None
):
def
function_type
(
self
,
self_arg_override
=
None
):
# Construct a C function type descriptor for this signature
# Construct a C function type descriptor for this signature
args
=
[]
args
=
[]
for
i
in
x
range
(
self
.
num_fixed_args
()):
for
i
in
range
(
self
.
num_fixed_args
()):
if
self_arg_override
is
not
None
and
self
.
is_self_arg
(
i
):
if
self_arg_override
is
not
None
and
self
.
is_self_arg
(
i
):
assert
isinstance
(
self_arg_override
,
PyrexTypes
.
CFuncTypeArg
)
assert
isinstance
(
self_arg_override
,
PyrexTypes
.
CFuncTypeArg
)
args
.
append
(
self_arg_override
)
args
.
append
(
self_arg_override
)
...
...
This diff is collapsed.
Click to expand it.
Cython/Debugger/libpython.py
View file @
9498ab65
...
@@ -118,7 +118,7 @@ def safety_limit(val):
...
@@ -118,7 +118,7 @@ def safety_limit(val):
def
safe_range
(
val
):
def
safe_range
(
val
):
# As per range, but don't trust the value too much: cap it to a safety
# As per range, but don't trust the value too much: cap it to a safety
# threshold in case the data was corrupted
# threshold in case the data was corrupted
return
x
range
(
safety_limit
(
val
))
return
range
(
safety_limit
(
val
))
def
write_unicode
(
file
,
text
):
def
write_unicode
(
file
,
text
):
...
...
This diff is collapsed.
Click to expand it.
Cython/Plex/Regexps.py
View file @
9498ab65
...
@@ -87,9 +87,7 @@ def CodeRanges(code_list):
...
@@ -87,9 +87,7 @@ def CodeRanges(code_list):
Given a list of codes as returned by chars_to_ranges, return
Given a list of codes as returned by chars_to_ranges, return
an RE which will match a character in any of the ranges.
an RE which will match a character in any of the ranges.
"""
"""
re_list
=
[]
re_list
=
[
CodeRange
(
code_list
[
i
],
code_list
[
i
+
1
])
for
i
in
range
(
0
,
len
(
code_list
),
2
)]
for
i
in
xrange
(
0
,
len
(
code_list
),
2
):
re_list
.
append
(
CodeRange
(
code_list
[
i
],
code_list
[
i
+
1
]))
return
Alt
(
*
re_list
)
return
Alt
(
*
re_list
)
...
@@ -307,8 +305,7 @@ class Seq(RE):
...
@@ -307,8 +305,7 @@ class Seq(RE):
def
__init__
(
self
,
*
re_list
):
def
__init__
(
self
,
*
re_list
):
nullable
=
1
nullable
=
1
for
i
in
xrange
(
len
(
re_list
)):
for
i
,
re
in
enumerate
(
re_list
):
re
=
re_list
[
i
]
self
.
check_re
(
i
,
re
)
self
.
check_re
(
i
,
re
)
nullable
=
nullable
and
re
.
nullable
nullable
=
nullable
and
re
.
nullable
self
.
re_list
=
re_list
self
.
re_list
=
re_list
...
@@ -332,12 +329,11 @@ class Seq(RE):
...
@@ -332,12 +329,11 @@ class Seq(RE):
else
:
else
:
s1
=
initial_state
s1
=
initial_state
n
=
len
(
re_list
)
n
=
len
(
re_list
)
for
i
in
xrange
(
n
):
for
i
,
re
in
enumerate
(
re_list
):
if
i
<
n
-
1
:
if
i
<
n
-
1
:
s2
=
m
.
new_state
()
s2
=
m
.
new_state
()
else
:
else
:
s2
=
final_state
s2
=
final_state
re
=
re_list
[
i
]
re
.
build_machine
(
m
,
s1
,
s2
,
match_bol
,
nocase
)
re
.
build_machine
(
m
,
s1
,
s2
,
match_bol
,
nocase
)
s1
=
s2
s1
=
s2
match_bol
=
re
.
match_nl
or
(
match_bol
and
re
.
nullable
)
match_bol
=
re
.
match_nl
or
(
match_bol
and
re
.
nullable
)
...
...
This diff is collapsed.
Click to expand it.
Cython/Plex/Traditional.py
View file @
9498ab65
...
@@ -104,7 +104,7 @@ class REParser(object):
...
@@ -104,7 +104,7 @@ class REParser(object):
if
self
.
c
==
'-'
and
self
.
lookahead
(
1
)
!=
']'
:
if
self
.
c
==
'-'
and
self
.
lookahead
(
1
)
!=
']'
:
self
.
next
()
self
.
next
()
c2
=
self
.
get
()
c2
=
self
.
get
()
for
a
in
x
range
(
ord
(
c1
),
ord
(
c2
)
+
1
):
for
a
in
range
(
ord
(
c1
),
ord
(
c2
)
+
1
):
char_list
.
append
(
chr
(
a
))
char_list
.
append
(
chr
(
a
))
else
:
else
:
char_list
.
append
(
c1
)
char_list
.
append
(
c1
)
...
...
This diff is collapsed.
Click to expand it.
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