if result_type.is_reference:
result_type = result_type.ref_base_type
if result_type.is_pyobject:
- # any specific Python type is always safe to infer
- return result_type
+ # In theory, any specific Python type is always safe to
+ # infer. However, inferring str can cause some existing code
+ # to break, since we are also now much more strict about
+ # coercion from str to char *. See trac #553.
+ if result_type.name == 'str':
+ return py_object_type
+ else:
+ return result_type
elif result_type is PyrexTypes.c_double_type:
# Python's float type is just a C double, so it's safe to use
# the C type instead
res = ~d
assert typeof(d) == "long", typeof(d)
+ # we special-case inference to type str, see
+ # trac #
+ s = "abc"
+ assert typeof(s) == "Python object", typeof(s)
+
# potentially overflowing arithmetic
e = 1
e += 1