8000 FIX: Python 3.2 debug assertion · numpy/numpy@5ae12ea · GitHub
[go: up one dir, main page]

Skip to content

Commit 5ae12ea

Browse files
committed
FIX: Python 3.2 debug assertion
Fixes gh-646, gh-2731. The patch was originally attached to gh-646 by "skrah".
1 parent 26d1565 commit 5ae12ea

File tree

1 file changed

+16
-0
lines changed

1 file changed

+16
-0
lines changed

numpy/core/src/multiarray/common.c

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -174,7 +174,15 @@ PyArray_DTypeFromObjectHelper(PyObject *obj, int maxdims,
174174
if ((temp = PyObject_Str(obj)) == NULL) {
175175
return -1;
176176
}
177+
#if defined(NPY_PY3K)
178+
#if PY_VERSION_HEX >= 0x03030000
179+
itemsize = PyUnicode_GetLength(temp);
180+
#else
181+
itemsize = PyUnicode_GET_SIZE(temp);
182+
#endif
183+
#else
177184
itemsize = PyString_GET_SIZE(temp);
185+
#endif
178186
}
179187
else if (string_type == NPY_UNICODE) {
180188
#if defined(NPY_PY3K)
@@ -218,7 +226,15 @@ PyArray_DTypeFromObjectHelper(PyObject *obj, int maxdims,
218226
if ((temp = PyObject_Str(obj)) == NULL) {
219227
return -1;
220228
}
229+
#if defined(NPY_PY3K)
230+
#if PY_VERSION_HEX >= 0x03030000
231+
itemsize = PyUnicode_GetLength(temp);
232+
#else
233+
itemsize = PyUnicode_GET_SIZE(temp);
234+
#endif
235+
#else
221236
itemsize = PyString_GET_SIZE(temp);
237+
#endif
222238
}
223239
else if (string_type == NPY_UNICODE) {
224240
#if defined(NPY_PY3K)

0 commit comments

Comments
 (0)
0