From 5e702a5ec5b16b345abd76bd5c34e7e4590114d6 Mon Sep 17 00:00:00 2001 From: Stefan Behnel Date: Sat, 7 Dec 2013 14:15:13 +0100 Subject: [PATCH] fix return type of repr(): CPython guarantees to return str --- Cython/Compiler/Builtin.py | 2 +- tests/compile/builtinfuncs.pyx | 4 ++++ 2 files changed, 5 insertions(+), 1 deletion(-) diff --git a/Cython/Compiler/Builtin.py b/Cython/Compiler/Builtin.py index bb42a23..a33bcfe 100644 --- a/Cython/Compiler/Builtin.py +++ b/Cython/Compiler/Builtin.py @@ -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', "", "", ""), diff --git a/tests/compile/builtinfuncs.pyx b/tests/compile/builtinfuncs.pyx index b64de1d..712a325 100644 --- a/tests/compile/builtinfuncs.pyx +++ b/tests/compile/builtinfuncs.pyx @@ -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) -- 2.7.4