summaryrefslogtreecommitdiff
path: root/numpy
diff options
context:
space:
mode:
Diffstat (limited to 'numpy')
-rw-r--r--numpy/core/src/multiarray/scalarapi.c6
-rw-r--r--numpy/core/src/multiarray/ucsnarrow.c16
2 files changed, 18 insertions, 4 deletions
diff --git a/numpy/core/src/multiarray/scalarapi.c b/numpy/core/src/multiarray/scalarapi.c
index e43e0dbe8..5afa61a1c 100644
--- a/numpy/core/src/multiarray/scalarapi.c
+++ b/numpy/core/src/multiarray/scalarapi.c
@@ -707,7 +707,11 @@ PyArray_Scalar(void *data, PyArray_Descr *descr, PyObject *base)
#endif
/* Need an extra slot and need to use Python memory manager */
uni->str = NULL;
- destptr = PyMem_NEW(Py_UNICODE,length+1);
+#if PY_VERSION_HEX >= 0x02070000
+ destptr = PyObject_MALLOC(sizeof(Py_UNICODE) * (length + 1));
+#else
+ destptr = PyMem_NEW(Py_UNICODE, length + 1);
+#endif
if (destptr == NULL) {
Py_DECREF(obj);
return PyErr_NoMemory();
diff --git a/numpy/core/src/multiarray/ucsnarrow.c b/numpy/core/src/multiarray/ucsnarrow.c
index 607ed834f..c192bbd1c 100644
--- a/numpy/core/src/multiarray/ucsnarrow.c
+++ b/numpy/core/src/multiarray/ucsnarrow.c
@@ -90,8 +90,14 @@ MyPyUnicode_New(int length)
{
PyUnicodeObject *unicode;
unicode = PyObject_New(PyUnicodeObject, &PyUnicode_Type);
- if (unicode == NULL) return NULL;
- unicode->str = PyMem_NEW(Py_UNICODE, length+1);
+ if (unicode == NULL) {
+ return NULL;
+ }
+#if PY_VERSION_HEX >= 0x02070000
+ unicode->str = PyObject_MALLOC(sizeof(Py_UNICODE) * (length + 1));
+#else
+ unicode->str = PyMem_NEW(Py_UNICODE, length + 1);
+#endif
if (!unicode->str) {
_Py_ForgetReference((PyObject *)unicode);
PyObject_Del(unicode);
@@ -114,7 +120,11 @@ MyPyUnicode_Resize(PyUnicodeObject *uni, int length)
void *oldstr;
oldstr = uni->str;
- PyMem_RESIZE(uni->str, Py_UNICODE, length+1);
+#if PY_VERSION_HEX >= 0x02070000
+ PyObject_REALLOC(uni->str, sizeof(Py_UNICODE) * (length + 1));
+#else
+ PyMem_RESIZE(uni->str, Py_UNICODE, length + 1);
+#endif
if (!uni->str) {
uni->str = oldstr;
PyErr_NoMemory();