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
4a8ce7c1
Commit
4a8ce7c1
authored
May 13, 2011
by
Stefan Behnel
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
fix compiler crash on sliced bytes iteration by disabling the optimisation, minor cleanups
parent
9b67cc67
Changes
2
Show whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
25 additions
and
2 deletions
+25
-2
Cython/Compiler/Optimize.py
Cython/Compiler/Optimize.py
+5
-2
tests/run/for_in_string.pyx
tests/run/for_in_string.pyx
+20
-0
No files found.
Cython/Compiler/Optimize.py
View file @
4a8ce7c1
...
...
@@ -157,7 +157,7 @@ class IterationTransform(Visitor.VisitorTransform):
plain_iterator
=
unwrap_coerced_node
(
iterator
)
if
isinstance
(
plain_iterator
,
ExprNodes
.
SliceIndexNode
)
and
\
(
plain_iterator
.
base
.
type
.
is_array
or
plain_iterator
.
base
.
type
.
is_ptr
):
return
self
.
_transform_carray_iteration
(
node
,
plain_iterator
)
return
self
.
_transform_carray_iteration
(
node
,
plain_iterator
,
reversed
=
reversed
)
if
iterator
.
type
.
is_ptr
or
iterator
.
type
.
is_array
:
return
self
.
_transform_carray_iteration
(
node
,
iterator
,
reversed
=
reversed
)
...
...
@@ -304,7 +304,7 @@ class IterationTransform(Visitor.VisitorTransform):
error
(
slice_node
.
pos
,
"C array iteration requires known end index"
)
return
node
elif
isinstance
(
slice_node
,
ExprNodes
.
IndexNode
):
# slice_node.index must be a SliceNode
assert
isinstance
(
slice_node
.
index
,
ExprNodes
.
SliceNode
)
slice_base
=
slice_node
.
base
index
=
slice_node
.
index
start
=
index
.
start
...
...
@@ -415,6 +415,9 @@ class IterationTransform(Visitor.VisitorTransform):
elif
node
.
target
.
type
.
is_ptr
and
not
node
.
target
.
type
.
assignable_from
(
ptr_type
.
base_type
):
# Allow iteration with pointer target to avoid copy.
target_value
=
counter_temp
elif
ptr_type
is
Builtin
.
bytes_type
:
# TODO: implement ...
return
node
else
:
target_value
=
ExprNodes
.
IndexNode
(
node
.
target
.
pos
,
...
...
tests/run/for_in_string.pyx
View file @
4a8ce7c1
...
...
@@ -49,6 +49,26 @@ def for_char_in_bytes(bytes s):
else
:
return
'X'
# TODO: implement (see Optimize.py:IterationTransform._transform_carray_iteration())
#@cython.test_assert_path_exists("//ForFromStatNode")
#@cython.test_fail_if_path_exists("//ForInStatNode")
def
for_obj_in_bytes_slice
(
bytes
s
):
"""
>>> for_obj_in_bytes_slice(bytes_abc)
'X'
>>> for_obj_in_bytes_slice(bytes_ABC)
'B'
>>> for_obj_in_bytes_slice(bytes_abc_null)
'X'
>>> for_obj_in_bytes_slice(bytes_ABC_null)
'B'
"""
for
c
in
s
[
1
:
-
1
]:
if
c
==
b'B'
:
return
'B'
else
:
return
'X'
@
cython
.
test_assert_path_exists
(
"//ForFromStatNode"
)
@
cython
.
test_fail_if_path_exists
(
"//ForInStatNode"
)
def
for_char_in_enumerate_bytes
(
bytes
s
):
...
...
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