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
Gwenaël Samain
cython
Commits
9c76f112
Commit
9c76f112
authored
Sep 09, 2010
by
Stefan Behnel
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
minor cleanup in type inference indexing
parent
59d44445
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
8 additions
and
6 deletions
+8
-6
Cython/Compiler/ExprNodes.py
Cython/Compiler/ExprNodes.py
+8
-6
No files found.
Cython/Compiler/ExprNodes.py
View file @
9c76f112
...
...
@@ -1946,6 +1946,7 @@ class IndexNode(ExprNode):
if
isinstance
(
self
.
index
,
SliceNode
):
# slicing!
if
base_type
.
is_string
:
# sliced C strings must coerce to Python
return
bytes_type
elif
base_type
in
(
unicode_type
,
bytes_type
,
str_type
,
list_type
,
tuple_type
):
# slicing these returns the same type
...
...
@@ -1954,12 +1955,6 @@ class IndexNode(ExprNode):
# TODO: Handle buffers (hopefully without too much redundancy).
return
py_object_type
if
isinstance
(
self
.
base
,
BytesNode
):
# Py2/3 return different types on indexing bytes objects
# and we can't be sure if we are slicing, so we can't do
# any better than this:
return
py_object_type
index_type
=
self
.
index
.
infer_type
(
env
)
if
index_type
and
index_type
.
is_int
or
isinstance
(
self
.
index
,
(
IntNode
,
LongNode
)):
# indexing!
...
...
@@ -1972,9 +1967,16 @@ class IndexNode(ExprNode):
# to receive it, throw it away, and potentially rebuild it
# on a subsequent PyObject coercion.
return
PyrexTypes
.
c_py_unicode_type
elif
isinstance
(
self
.
base
,
BytesNode
):
#if env.global_scope().context.language_level >= 3:
# # infering 'char' can be made to work in Python 3 mode
# return PyrexTypes.c_char_type
# Py2/3 return different types on indexing bytes objects
return
py_object_type
elif
base_type
.
is_ptr
or
base_type
.
is_array
:
return
base_type
.
base_type
# may be slicing or indexing, we don't know
if
base_type
is
unicode_type
:
# this type always returns its own type on Python indexing/slicing
return
base_type
...
...
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