summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorPauli Virtanen <pav@iki.fi>2010-02-20 18:12:46 +0000
committerPauli Virtanen <pav@iki.fi>2010-02-20 18:12:46 +0000
commitc0815c57512859e7e05c6b97d05350c2c2f68e81 (patch)
tree48db2bb8eebf7e3ee1d9343adf1a20d652dc919d
parentcb8c9b33c94d078e56e5ffaf22061aeab317d3a1 (diff)
downloadnumpy-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.src8
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;