[Numpy-svn] r8163 - trunk/numpy/core/src/multiarray

numpy-svn@scip... numpy-svn@scip...
Sat Feb 20 12:12:46 CST 2010


Author: ptvirtan
Date: 2010-02-20 12:12:46 -0600 (Sat, 20 Feb 2010)
New Revision: 8163

Modified:
   trunk/numpy/core/src/multiarray/scalartypes.c.src
Log:
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

Modified: trunk/numpy/core/src/multiarray/scalartypes.c.src
===================================================================
--- trunk/numpy/core/src/multiarray/scalartypes.c.src	2010-02-20 18:12:29 UTC (rev 8162)
+++ trunk/numpy/core/src/multiarray/scalartypes.c.src	2010-02-20 18:12:46 UTC (rev 8163)
@@ -1328,6 +1328,14 @@
     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;



More information about the Numpy-svn mailing list