Ond??ej ??ert??k <ondrej.cer...@gmail.com> wrote: > So at some point, the strings get converted to numpy strings in 3.2, > but not in 3.3.
PyArray_Scalar() must return a subtype of PyUnicodeObject. I'm boldly assuming that data is in utf-32. If so, then this unoptimized version should work: diff --git a/numpy/core/src/multiarray/scalarapi.c b/numpy/core/src/multiarray/scalarapi.c index 2e255c0..c134aed 100644 --- a/numpy/core/src/multiarray/scalarapi.c +++ b/numpy/core/src/multiarray/scalarapi.c @@ -643,7 +643,20 @@ PyArray_Scalar(void *data, PyArray_Descr *descr, PyObject *base) } #if PY_VERSION_HEX >= 0x03030000 if (type_num == NPY_UNICODE) { - return PyUnicode_FromKindAndData(PyUnicode_4BYTE_KIND, data, itemsize/4); + PyObject *b, *args; + b = PyBytes_FromStringAndSize(data, itemsize); + if (b == NULL) { + return NULL; + } + args = Py_BuildValue("(Os)", b, "utf-32"); + if (args == NULL) { + Py_DECREF(b); + return NULL; + } + obj = type->tp_new(type, args, NULL); + Py_DECREF(b); + Py_DECREF(args); + return obj; } #endif if (type->tp_itemsize != 0) { Stefan Krah _______________________________________________ NumPy-Discussion mailing list NumPy-Discussion@scipy.org http://mail.scipy.org/mailman/listinfo/numpy-discussion