From: Stefan Behnel Date: Sat, 2 Nov 2013 21:00:04 +0000 (+0100) Subject: fix C pointer coercion problem when coercing bytes to signed char* X-Git-Url: http://review.tizen.org/git/?a=commitdiff_plain;h=fe77570aceeb848f45b90638b2f89aa2ae4c26ea;p=platform%2Fupstream%2Fpython-cython.git fix C pointer coercion problem when coercing bytes to signed char* --- diff --git a/Cython/Compiler/PyrexTypes.py b/Cython/Compiler/PyrexTypes.py index 0051d3d..9acb103 100644 --- a/Cython/Compiler/PyrexTypes.py +++ b/Cython/Compiler/PyrexTypes.py @@ -2085,7 +2085,10 @@ class CPointerBaseType(CType): if base_type.signed: self.to_py_function = "__Pyx_PyObject_FromString" if self.is_ptr: - self.from_py_function = "__Pyx_PyObject_AsString" + if base_type.signed == 2: + self.from_py_function = "__Pyx_PyObject_AsSString" + else: + self.from_py_function = "__Pyx_PyObject_AsString" else: self.to_py_function = "__Pyx_PyObject_FromUString" if self.is_ptr: diff --git a/Cython/Utility/TypeConversion.c b/Cython/Utility/TypeConversion.c index 7046d60..2a41caa 100644 --- a/Cython/Utility/TypeConversion.c +++ b/Cython/Utility/TypeConversion.c @@ -19,6 +19,7 @@ static CYTHON_INLINE PyObject* __Pyx_PyUnicode_FromString(char*); #define __Pyx_PyStr_FromStringAndSize __Pyx_PyUnicode_FromStringAndSize #endif +#define __Pyx_PyObject_AsSString(s) ((signed char*) __Pyx_PyObject_AsString(s)) #define __Pyx_PyObject_AsUString(s) ((unsigned char*) __Pyx_PyObject_AsString(s)) #define __Pyx_PyObject_FromUString(s) __Pyx_PyObject_FromString((char*)s) #define __Pyx_PyBytes_FromUString(s) __Pyx_PyBytes_FromString((char*)s)