# to receive it, throw it away, and potentially rebuild it
# on a subsequent PyObject coercion.
return PyrexTypes.c_py_ucs4_type
+ elif base_type is str_type:
+ # always returns str - Py2: bytes, Py3: unicode
+ return base_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
b = b"abc"
assert typeof(b) == "bytes object", typeof(b)
b1 = b[1]
- assert typeof(b1) == "Python object", typeof(b1)
+ assert typeof(b1) == "Python object", typeof(b1) # Py2: bytes, Py3: int
u = u"xyz"
assert typeof(u) == "unicode object", typeof(u)
u1 = u[1]
s = "xyz"
assert typeof(s) == "str object", typeof(s)
s1 = s[1]
- assert typeof(s1) == "Python object", typeof(s1)
+ assert typeof(s1) == "str object", typeof(s1)
L = [1,2,3]
assert typeof(L) == "list object", typeof(L)
L1 = L[1]
Python object
"""
cdef bytes bytes_string = b'abcdefg'
+ # bytes in Py2, int in Py3
for c in bytes_string:
pass
return typeof(c)
def loop_over_str():
"""
>>> print( loop_over_str() )
- Python object
+ str object
"""
cdef str string = 'abcdefg'
+ # str (bytes) in Py2, str (unicode) in Py3
for c in string:
pass
return typeof(c)
Py_UCS4
"""
cdef unicode ustring = u'abcdefg'
+ # Py_UCS4 can represent any Unicode character
for uchar in ustring:
pass
return typeof(uchar)