fix C pointer coercion problem when coercing bytes to signed char*
authorStefan Behnel <stefan_ml@behnel.de>
Sat, 2 Nov 2013 21:00:04 +0000 (22:00 +0100)
committerStefan Behnel <stefan_ml@behnel.de>
Sat, 2 Nov 2013 21:00:04 +0000 (22:00 +0100)
Cython/Compiler/PyrexTypes.py
Cython/Utility/TypeConversion.c

index 0051d3d..9acb103 100644 (file)
@@ -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:
index 7046d60..2a41caa 100644 (file)
@@ -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)