fix return type of repr(): CPython guarantees to return str
authorStefan Behnel <stefan_ml@behnel.de>
Sat, 7 Dec 2013 13:15:13 +0000 (14:15 +0100)
committerStefan Behnel <stefan_ml@behnel.de>
Sat, 7 Dec 2013 13:15:13 +0000 (14:15 +0100)
Cython/Compiler/Builtin.py
tests/compile/builtinfuncs.pyx

index bb42a23..a33bcfe 100644 (file)
@@ -215,7 +215,7 @@ builtin_function_table = [
     #('raw_input', "",     "",      ""),
     #('reduce',    "",     "",      ""),
     BuiltinFunction('reload',     "O",    "O",     "PyImport_ReloadModule"),
-    BuiltinFunction('repr',       "O",    "O",     "PyObject_Repr", builtin_return_type='basestring'),
+    BuiltinFunction('repr',       "O",    "O",     "PyObject_Repr", builtin_return_type='str'),
     #('round',     "",     "",      ""),
     BuiltinFunction('setattr',    "OOO",  "r",     "PyObject_SetAttr"),
     #('sum',       "",     "",      ""),
index b64de1d..712a325 100644 (file)
@@ -2,6 +2,8 @@
 
 cdef int f() except -1:
     cdef object x, y = 0, z = 0, w = 0
+    cdef str sstring
+    cdef basestring sustring
     cdef int i
     x = abs(y)
     delattr(x, 'spam')
@@ -20,6 +22,8 @@ cdef int f() except -1:
     x = pow(y, z)
     x = reload(y)
     x = repr(y)
+    sstring = repr(x)
+    sustring = repr(x)
     setattr(x, y, z)
     #i = typecheck(x, y)
     #i = issubtype(x, y)