Permalink
Browse files

FIX: Python 3.2 debug assertion

Fixes gh-646, gh-2731. The patch was originally attached to gh-646 by "skrah".
  • Loading branch information...
1 parent 26d1565 commit 5ae12eacb81c9c160b2977ad46d668f5a1c37229 @certik certik committed Nov 13, 2012
Showing with 16 additions and 0 deletions.
  1. +16 −0 numpy/core/src/multiarray/common.c
@@ -174,7 +174,15 @@ PyArray_DTypeFromObjectHelper(PyObject *obj, int maxdims,
if ((temp = PyObject_Str(obj)) == NULL) {
return -1;
}
+#if defined(NPY_PY3K)
+ #if PY_VERSION_HEX >= 0x03030000
+ itemsize = PyUnicode_GetLength(temp);
+ #else
+ itemsize = PyUnicode_GET_SIZE(temp);
+ #endif
+#else
itemsize = PyString_GET_SIZE(temp);
+#endif
}
else if (string_type == NPY_UNICODE) {
#if defined(NPY_PY3K)
@@ -218,7 +226,15 @@ PyArray_DTypeFromObjectHelper(PyObject *obj, int maxdims,
if ((temp = PyObject_Str(obj)) == NULL) {
return -1;
}
+#if defined(NPY_PY3K)
+ #if PY_VERSION_HEX >= 0x03030000
+ itemsize = PyUnicode_GetLength(temp);
+ #else
+ itemsize = PyUnicode_GET_SIZE(temp);
+ #endif
+#else
itemsize = PyString_GET_SIZE(temp);
+#endif
}
else if (string_type == NPY_UNICODE) {
#if defined(NPY_PY3K)

0 comments on commit 5ae12ea

Please sign in to comment.