Blob Blame History Raw
From f6b64c942fb91e6c261fa455969a38482c22beeb Mon Sep 17 00:00:00 2001
From: Antonio Valentino <antonio.valentino@tiscali.it>
Date: Tue, 1 Jan 2019 12:25:43 +0100
Subject: [PATCH] Fix issue with not writeable buffer (numpy 1.16 compat)

---
 tables/hdf5extension.pyx | 7 +++++--
 1 file changed, 5 insertions(+), 2 deletions(-)

diff --git a/tables/hdf5extension.pyx b/tables/hdf5extension.pyx
index 6dc32f48..e64d1a1b 100644
--- a/tables/hdf5extension.pyx
+++ b/tables/hdf5extension.pyx
@@ -111,6 +111,9 @@ from utilsextension cimport malloc_dims, get_native_type, cstr_to_pystr, load_re
 
 #-------------------------------------------------------------------
 
+cdef extern from "Python.h":
+
+    object PyByteArray_FromStringAndSize(char *s, Py_ssize_t len)
 
 # Functions from HDF5 ARRAY (this is not part of HDF5 HL; it's private)
 cdef extern from "H5ARRAY.h" nogil:
@@ -2141,8 +2144,8 @@ cdef class VLArray(Leaf):
         # Create a buffer to keep this info. It is important to do a
         # copy, because we will dispose the buffer memory later on by
         # calling the H5Dvlen_reclaim. PyBytes_FromStringAndSize does this.
-        buf = PyBytes_FromStringAndSize(<char *>rdata[i].p,
-                                        vllen*self._atomicsize)
+        buf = PyByteArray_FromStringAndSize(<char *>rdata[i].p,
+                                            vllen*self._atomicsize)
       else:
         # Case where there is info with zero lentgh
         buf = None