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
Labels
Merge Requests
0
Merge Requests
0
Analytics
Analytics
Repository
Value Stream
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Commits
Open sidebar
nexedi
cython
Commits
967f8db2
Commit
967f8db2
authored
May 14, 2010
by
Stefan Behnel
Browse files
Options
Browse Files
Download
Plain Diff
merged in latest cython-devel
parents
16fb7e25
8be7e855
Changes
6
Hide whitespace changes
Inline
Side-by-side
Showing
6 changed files
with
55 additions
and
7 deletions
+55
-7
Cython/Compiler/ExprNodes.py
Cython/Compiler/ExprNodes.py
+1
-1
Cython/Compiler/Options.py
Cython/Compiler/Options.py
+2
-2
Cython/Compiler/Parsing.py
Cython/Compiler/Parsing.py
+1
-1
Cython/Compiler/TypeInference.py
Cython/Compiler/TypeInference.py
+9
-1
tests/run/trybreak.pyx
tests/run/trybreak.pyx
+2
-2
tests/run/type_inference.pyx
tests/run/type_inference.pyx
+40
-0
No files found.
Cython/Compiler/ExprNodes.py
View file @
967f8db2
...
...
@@ -5624,7 +5624,7 @@ class CmpNode(object):
# Mixin class containing code common to PrimaryCmpNodes
# and CascadedCmpNodes.
def
infer_type
s
(
self
,
env
):
def
infer_type
(
self
,
env
):
# TODO: Actually implement this (after merging with -unstable).
return
py_object_type
...
...
Cython/Compiler/Options.py
View file @
967f8db2
...
...
@@ -21,10 +21,10 @@ annotate = 0
# This will convert statements of the form "for i in range(...)"
# to "for i from ..." when i is a cdef'd integer type, and the direction
# (i.e. sign of step) can be determined.
# WARNING: This may change the s
y
mantics if the range causes assignment to
# WARNING: This may change the s
e
mantics if the range causes assignment to
# i to overflow. Specifically, if this option is set, an error will be
# raised before the loop is entered, wheras without this option the loop
# will execute u
til a
overflowing value is encountered.
# will execute u
ntil an
overflowing value is encountered.
convert_range
=
1
# Enable this to allow one to write your_module.foo = ... to overwrite the
...
...
Cython/Compiler/Parsing.py
View file @
967f8db2
...
...
@@ -673,7 +673,7 @@ def p_opt_string_literal(s):
def
p_string_literal
(
s
,
kind_override
=
None
):
# A single string or char literal.
# Returns (kind, value) where kind in ('b', 'c', 'u')
# Returns (kind, value) where kind in ('b', 'c', 'u'
, ''
)
# s.sy == 'BEGIN_STRING'
pos
=
s
.
position
()
is_raw
=
0
...
...
Cython/Compiler/TypeInference.py
View file @
967f8db2
...
...
@@ -70,7 +70,15 @@ class MarkAssignments(CythonTransform):
sequence
.
args
[
0
],
sequence
.
args
[
2
]))
if
not
is_special
:
self
.
mark_assignment
(
node
.
target
,
object_expr
)
# A for-loop basically translates to subsequent calls to
# __getitem__(), so using an IndexNode here allows us to
# naturally infer the base type of pointers, C arrays,
# Python strings, etc., while correctly falling back to an
# object type when the base type cannot be handled.
self
.
mark_assignment
(
node
.
target
,
ExprNodes
.
IndexNode
(
node
.
pos
,
base
=
sequence
,
index
=
ExprNodes
.
IntNode
(
node
.
pos
,
value
=
'0'
)))
self
.
visitchildren
(
node
)
return
node
...
...
tests/run/trybreak.pyx
View file @
967f8db2
...
...
@@ -5,12 +5,12 @@ a
# Indirectly makes sure the cleanup happens correctly on breaking.
def
foo
():
for
x
in
u
"abc"
:
for
x
in
"abc"
:
try
:
x
()
except
:
break
for
x
in
u
"abc"
:
for
x
in
"abc"
:
try
:
x
()
except
:
...
...
tests/run/type_inference.pyx
View file @
967f8db2
...
...
@@ -187,6 +187,46 @@ def loop():
pass
assert
typeof
(
a
)
==
"long"
def
loop_over_charptr
():
"""
>>> print( loop_over_charptr() )
char
"""
cdef
char
*
char_ptr_string
=
'abcdefg'
for
c
in
char_ptr_string
:
pass
return
typeof
(
c
)
def
loop_over_bytes
():
"""
>>> print( loop_over_bytes() )
Python object
"""
cdef
bytes
bytes_string
=
b'abcdefg'
for
c
in
bytes_string
:
pass
return
typeof
(
c
)
def
loop_over_unicode
():
"""
>>> print( loop_over_unicode() )
Py_UNICODE
"""
cdef
unicode
ustring
=
u'abcdefg'
for
uchar
in
ustring
:
pass
return
typeof
(
uchar
)
def
loop_over_int_array
():
"""
>>> print( loop_over_int_array() )
int
"""
cdef
int
[
10
]
int_array
for
i
in
int_array
:
pass
return
typeof
(
i
)
cdef
unicode
retu
():
return
u"12345"
...
...
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