when indexing/slicing 'str', it's safe to infer 'str' for the result
authorStefan Behnel <scoder@users.berlios.de>
Sun, 6 Feb 2011 15:14:48 +0000 (16:14 +0100)
committerStefan Behnel <scoder@users.berlios.de>
Sun, 6 Feb 2011 15:14:48 +0000 (16:14 +0100)
Cython/Compiler/ExprNodes.py

index 07b0db220fadc1672e25c3390f8300e32e8c690a..86a26c7cc074f1ca4004f99f0d82f57e5806a4f8 100755 (executable)
@@ -2087,8 +2087,8 @@ class IndexNode(ExprNode):
                 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
+        if base_type in (unicode_type, str_type):
+            # these types always returns their own type on Python indexing/slicing
             return base_type
         else:
             # TODO: Handle buffers (hopefully without too much redundancy).