diff options
author | Pauli Virtanen <pav@iki.fi> | 2010-02-20 18:12:46 +0000 |
---|---|---|
committer | Pauli Virtanen <pav@iki.fi> | 2010-02-20 18:12:46 +0000 |
commit | c0815c57512859e7e05c6b97d05350c2c2f68e81 (patch) | |
tree | 48db2bb8eebf7e3ee1d9343adf1a20d652dc919d | |
parent | cb8c9b33c94d078e56e5ffaf22061aeab317d3a1 (diff) | |
download | numpy-c0815c57512859e7e05c6b97d05350c2c2f68e81.tar.gz |
3K: core: fix pickling of unicode scalars on Py3 -- they do not have buffer interface, so we need to get the buffer via the standard route
-rw-r--r-- | numpy/core/src/multiarray/scalartypes.c.src | 8 |
1 files changed, 8 insertions, 0 deletions
diff --git a/numpy/core/src/multiarray/scalartypes.c.src b/numpy/core/src/multiarray/scalartypes.c.src index 8e705b3ef..fbe81abd4 100644 --- a/numpy/core/src/multiarray/scalartypes.c.src +++ b/numpy/core/src/multiarray/scalartypes.c.src @@ -1328,6 +1328,14 @@ gentype_reduce(PyObject *self, PyObject *NPY_UNUSED(args)) if (ret == NULL) { return NULL; } +#if defined(NPY_PY3K) + if (PyArray_IsScalar(self, Unicode)) { + /* Unicode on Python 3 does not expose the buffer interface */ + buffer = PyUnicode_AS_DATA(self); + buflen = PyUnicode_GET_DATA_SIZE(self); + } + else +#endif if (PyObject_AsReadBuffer(self, (const void **)&buffer, &buflen)<0) { Py_DECREF(ret); return NULL; |