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
f925d315
Commit
f925d315
authored
Apr 17, 2012
by
Stefan Behnel
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
properly coerce Py_UCS4 characters to a unicode string when for-loop target requires it
parent
afe1395f
Changes
4
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
41 additions
and
6 deletions
+41
-6
Cython/Compiler/Optimize.py
Cython/Compiler/Optimize.py
+10
-6
tests/run/cython3.pyx
tests/run/cython3.pyx
+10
-0
tests/run/py_ucs4_type.pyx
tests/run/py_ucs4_type.pyx
+11
-0
tests/run/type_inference.pyx
tests/run/type_inference.pyx
+10
-0
No files found.
Cython/Compiler/Optimize.py
View file @
f925d315
...
...
@@ -348,15 +348,19 @@ class IterationTransform(Visitor.VisitorTransform):
is_temp
=
False
,
))
target_value
=
ExprNodes
.
PythonCapiCallNode
(
slice_node
.
pos
,
"__Pyx_PyUnicode_READ"
,
self
.
PyUnicode_READ_func_type
,
args
=
[
kind_temp
,
data_temp
,
counter_temp
],
is_temp
=
False
,
)
if
target_value
.
type
!=
node
.
target
.
type
:
target_value
=
target_value
.
coerce_to
(
node
.
target
.
type
,
self
.
current_scope
)
target_assign
=
Nodes
.
SingleAssignmentNode
(
pos
=
node
.
target
.
pos
,
lhs
=
node
.
target
,
rhs
=
ExprNodes
.
PythonCapiCallNode
(
slice_node
.
pos
,
"__Pyx_PyUnicode_READ"
,
self
.
PyUnicode_READ_func_type
,
args
=
[
kind_temp
,
data_temp
,
counter_temp
],
is_temp
=
False
,
))
rhs
=
target_value
)
body
=
Nodes
.
StatListNode
(
node
.
pos
,
stats
=
[
target_assign
,
node
.
body
])
...
...
tests/run/cython3.pyx
View file @
f925d315
...
...
@@ -81,6 +81,16 @@ def str_type_is_unicode():
cdef
str
s
=
'abc'
return
str
,
s
def
loop_over_unicode_literal
():
"""
>>> print( loop_over_unicode_literal() )
Py_UCS4
"""
# Py_UCS4 can represent any Unicode character
for
uchar
in
'abcdefg'
:
pass
return
cython
.
typeof
(
uchar
)
def
list_comp
():
"""
>>> list_comp()
...
...
tests/run/py_ucs4_type.pyx
View file @
f925d315
...
...
@@ -201,6 +201,17 @@ def count_lower_case_characters_slice_reversed(unicode ustring):
count
+=
1
return
count
def
loop_object_over_unicode_literal
():
"""
>>> print(loop_object_over_unicode_literal())
abcdefg
"""
cdef
object
uchar
chars
=
[]
for
uchar
in
u'abcdefg'
:
chars
.
append
(
uchar
)
return
u''
.
join
(
chars
)
@
cython
.
test_assert_path_exists
(
'//SwitchStatNode'
)
@
cython
.
test_fail_if_path_exists
(
'//ForInStatNode'
)
def
iter_and_in
():
...
...
tests/run/type_inference.pyx
View file @
f925d315
...
...
@@ -341,6 +341,16 @@ def loop_over_unicode():
pass
return
typeof
(
uchar
)
def
loop_over_unicode_literal
():
"""
>>> print( loop_over_unicode_literal() )
Py_UCS4
"""
# Py_UCS4 can represent any Unicode character
for
uchar
in
u'abcdefg'
:
pass
return
typeof
(
uchar
)
def
loop_over_int_array
():
"""
>>> print( loop_over_int_array() )
...
...
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