Commit 5091aefd authored by Stefan Behnel's avatar Stefan Behnel

changed Python C-API usage test case to test includes from Cython/Includes/,...

changed Python C-API usage test case to test includes from Cython/Includes/, currently fails: are cimports in .pxd files not re-exported?
parent 01be3445
__doc__ = u""" __doc__ = u"""
>>> x = spam() >>> x = spam()
>>> print(repr(x)) >>> print(repr(x))
b'Ftang\\x00Ftang!' u'Ftang\\x00Ftang!'
""" """
import sys import sys
if sys.version_info[0] < 3: if sys.version_info[0] >= 3:
__doc__ = __doc__.replace(u" b'", u" '") __doc__ = __doc__.replace(u" u'", u" '")
cdef extern from "string.h": cdef extern from "string.h":
void memcpy(char *d, char *s, int n) void memcpy(char *d, char *s, int n)
cdef extern from "Python.h": from python cimport PyUnicode_DecodeUTF8
object PyString_FromStringAndSize(char *s, int len)
def spam(): def spam():
cdef char buf[12] cdef char buf[12]
memcpy(buf, "Ftang\0Ftang!", sizeof(buf)) memcpy(buf, "Ftang\0Ftang!", sizeof(buf))
return PyString_FromStringAndSize(buf, sizeof(buf)) return PyUnicode_DecodeUTF8(buf, sizeof(buf), NULL)
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment