changed Python C-API usage test case to test includes from Cython/Includes/, currentl...
authorStefan Behnel <scoder@users.berlios.de>
Fri, 22 Aug 2008 07:08:07 +0000 (09:08 +0200)
committerStefan Behnel <scoder@users.berlios.de>
Fri, 22 Aug 2008 07:08:07 +0000 (09:08 +0200)
tests/run/r_pythonapi.pyx

index edf3ddaae48e378449988751ae03ff178d7ade80..9fda34a6f9a7171bc745c0a9c150e8b66111620c 100644 (file)
@@ -1,20 +1,19 @@
 __doc__ = u"""
     >>> x = spam()
     >>> print(repr(x))
-    b'Ftang\\x00Ftang!'
+    u'Ftang\\x00Ftang!'
 """
 
 import sys
-if sys.version_info[0] < 3:
-    __doc__ = __doc__.replace(u" b'", u" '")
+if sys.version_info[0] >= 3:
+    __doc__ = __doc__.replace(u" u'", u" '")
 
 cdef extern from "string.h":
     void memcpy(char *d, char *s, int n)
 
-cdef extern from "Python.h":
-    object PyString_FromStringAndSize(char *s, int len)
+from python cimport PyUnicode_DecodeUTF8
     
 def spam():
     cdef char buf[12]
     memcpy(buf, "Ftang\0Ftang!", sizeof(buf))
-    return PyString_FromStringAndSize(buf, sizeof(buf))
+    return PyUnicode_DecodeUTF8(buf, sizeof(buf), NULL)