diff options
author | Pauli Virtanen <pav@iki.fi> | 2010-02-20 18:11:38 +0000 |
---|---|---|
committer | Pauli Virtanen <pav@iki.fi> | 2010-02-20 18:11:38 +0000 |
commit | 4662956d7c4f1e76468d8e161f33928f20983679 (patch) | |
tree | 549a0c3a64daef3fc032de49694bbd14e2828926 | |
parent | f8012ce42ee9ce709d2f4044e74e61d5d292b3cd (diff) | |
download | numpy-4662956d7c4f1e76468d8e161f33928f20983679.tar.gz |
3K: core: allow unicode type strings in __array_interface__ since we allow those also in dtypes
-rw-r--r-- | numpy/core/src/multiarray/ctors.c | 13 |
1 files changed, 12 insertions, 1 deletions
diff --git a/numpy/core/src/multiarray/ctors.c b/numpy/core/src/multiarray/ctors.c index 507119993..4dc169f90 100644 --- a/numpy/core/src/multiarray/ctors.c +++ b/numpy/core/src/multiarray/ctors.c @@ -2260,11 +2260,22 @@ PyArray_FromInterface(PyObject *input) } } attr = tstr; - if (!PyString_Check(attr)) { +#if defined(NPY_PY3K) + if (PyUnicode_Check(tstr)) { + /* Allow unicode type strings */ + attr = PyUnicode_AsASCIIString(tstr); + } +#endif + if (!PyBytes_Check(attr)) { PyErr_SetString(PyExc_TypeError, "typestr must be a string"); goto fail; } type = _array_typedescr_fromstr(PyString_AS_STRING(attr)); +#if defined(NPY_PY3K) + if (attr != tstr) { + Py_DECREF(attr); + } +#endif if (type == NULL) { goto fail; } |