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
9d5aaeab
Commit
9d5aaeab
authored
May 17, 2010
by
Stefan Behnel
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
fix indexing for inferred Py_UNICODE 'strings'
parent
b98d07fd
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
21 additions
and
0 deletions
+21
-0
Cython/Compiler/ExprNodes.py
Cython/Compiler/ExprNodes.py
+9
-0
tests/run/py_unicode_type.pyx
tests/run/py_unicode_type.pyx
+12
-0
No files found.
Cython/Compiler/ExprNodes.py
View file @
9d5aaeab
...
...
@@ -1983,6 +1983,15 @@ class IndexNode(ExprNode):
elif
not
skip_child_analysis
:
self
.
index
.
analyse_types
(
env
)
self
.
original_index_type
=
self
.
index
.
type
if
base_type
is
PyrexTypes
.
c_py_unicode_type
:
# we infer Py_UNICODE for unicode strings in some
# cases, but indexing must still work for them
if
self
.
index
.
constant_result
in
(
0
,
-
1
):
# FIXME: we know that this node is redundant -
# currently, this needs to get handled in Optimize.py
pass
self
.
base
=
self
.
base
.
coerce_to_pyobject
(
env
)
base_type
=
self
.
base
.
type
if
base_type
.
is_pyobject
:
if
self
.
index
.
type
.
is_int
:
if
(
not
setting
...
...
tests/run/py_unicode_type.pyx
View file @
9d5aaeab
...
...
@@ -130,6 +130,18 @@ def len_uchar(Py_UNICODE uchar):
"""
return
len
(
uchar
)
def
index_uchar
(
Py_UNICODE
uchar
,
Py_ssize_t
i
):
"""
>>> index_uchar(ord('A'), 0) == ('A', 'A', 'A')
True
>>> index_uchar(ord('A'), -1) == ('A', 'A', 'A')
True
>>> index_uchar(ord('A'), 1)
Traceback (most recent call last):
IndexError: string index out of range
"""
return
uchar
[
0
],
uchar
[
-
1
],
uchar
[
i
]
mixed_ustring
=
u'AbcDefGhIjKlmnoP'
lower_ustring
=
mixed_ustring
.
lower
()
upper_ustring
=
mixed_ustring
.
lower
()
...
...
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