forked from pool/python-numpy
- Add numpy-python33.patch to fix compilation with Python 3.3 OBS-URL: https://build.opensuse.org/request/show/141145 OBS-URL: https://build.opensuse.org/package/show/openSUSE:Factory/python-numpy?expand=0&rev=24
72 lines
2.5 KiB
Diff
72 lines
2.5 KiB
Diff
Index: numpy-1.6.2/numpy/core/src/multiarray/scalarapi.c
|
|
===================================================================
|
|
--- numpy-1.6.2.orig/numpy/core/src/multiarray/scalarapi.c
|
|
+++ numpy-1.6.2/numpy/core/src/multiarray/scalarapi.c
|
|
@@ -652,6 +652,34 @@ PyArray_Scalar(void *data, PyArray_Descr
|
|
itemsize = (((itemsize - 1) >> 2) + 1) << 2;
|
|
}
|
|
}
|
|
+#if PY_VERSION_HEX >= 0x03030000
|
|
+ if (type_num == NPY_UNICODE) {
|
|
+ PyObject *u, *args;
|
|
+ int byteorder;
|
|
+#if NPY_BYTE_ORDER == NPY_LITTLE_ENDIAN
|
|
+ byteorder = -1;
|
|
+#elif NPY_BYTE_ORDER == NPY_BIG_ENDIAN
|
|
+ byteorder = +1;
|
|
+#else
|
|
+ #error Endianness undefined ?
|
|
+#endif
|
|
+ if (swap) byteorder *= -1;
|
|
+
|
|
+ u = PyUnicode_DecodeUTF32(data, itemsize, NULL, &byteorder);
|
|
+ if (u == NULL) {
|
|
+ return NULL;
|
|
+ }
|
|
+ args = Py_BuildValue("(O)", u);
|
|
+ if (args == NULL) {
|
|
+ Py_DECREF(u);
|
|
+ return NULL;
|
|
+ }
|
|
+ obj = type->tp_new(type, args, NULL);
|
|
+ Py_DECREF(u);
|
|
+ Py_DECREF(args);
|
|
+ return obj;
|
|
+ }
|
|
+#endif
|
|
if (type->tp_itemsize != 0) {
|
|
/* String type */
|
|
obj = type->tp_alloc(type, itemsize);
|
|
@@ -688,6 +716,7 @@ PyArray_Scalar(void *data, PyArray_Descr
|
|
memcpy(destptr, data, itemsize);
|
|
return obj;
|
|
}
|
|
+#if PY_VERSION_HEX < 0x0303000
|
|
else if (type_num == PyArray_UNICODE) {
|
|
/* tp_alloc inherited from Python PyBaseObject_Type */
|
|
PyUnicodeObject *uni = (PyUnicodeObject*)obj;
|
|
@@ -759,6 +788,7 @@ PyArray_Scalar(void *data, PyArray_Descr
|
|
#endif
|
|
return obj;
|
|
}
|
|
+#endif // PY_VERSION_HEX < 0x03030000
|
|
else {
|
|
PyVoidScalarObject *vobj = (PyVoidScalarObject *)obj;
|
|
vobj->base = NULL;
|
|
Index: numpy-1.6.2/numpy/core/src/multiarray/scalartypes.c.src
|
|
===================================================================
|
|
--- numpy-1.6.2.orig/numpy/core/src/multiarray/scalartypes.c.src
|
|
+++ numpy-1.6.2/numpy/core/src/multiarray/scalartypes.c.src
|
|
@@ -2323,7 +2323,11 @@ finish:
|
|
*((npy_@name@ *)dest) = *((npy_@name@ *)src);
|
|
#elif @default@ == 1 /* unicode and strings */
|
|
if (itemsize == 0) { /* unicode */
|
|
+#if PY_VERSION_HEX >= 0x03030000
|
|
+ itemsize = PyUnicode_GetLength(robj) * PyUnicode_KIND(robj);
|
|
+#else
|
|
itemsize = ((PyUnicodeObject *)robj)->length * sizeof(Py_UNICODE);
|
|
+#endif
|
|
}
|
|
memcpy(dest, src, itemsize);
|
|
/* @default@ == 2 won't get here */
|