Accepting request 141145 from devel:languages:python
- 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
This commit is contained in:
committed by
Git OBS Bridge
parent
11254d45a3
commit
877f911204
71
numpy-python33.patch
Normal file
71
numpy-python33.patch
Normal file
@@ -0,0 +1,71 @@
|
||||
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 */
|
||||
Reference in New Issue
Block a user