Comaptibility with numpy 1.16
authorAntonio Valentino <antonio.valentino@tiscali.it>
Tue, 1 Jan 2019 08:46:46 +0000 (08:46 +0000)
committerAntonio Valentino <antonio.valentino@tiscali.it>
Wed, 2 Jan 2019 09:48:48 +0000 (09:48 +0000)
* fix not writeable buffers
* better handling of exception types

Gbp-Pq: Name 0005-Comaptibility-with-numpy-1.16.patch

tables/hdf5extension.pyx
tables/tests/test_array.py
tables/tests/test_lists.py

index 6dc32f48eaa3a9e84f69cd67b07e4bf0c3df2716..e64d1a1b8b2a3207f7e394b0117d4a7f0b2cbf27 100644 (file)
@@ -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
index b7d6a3f5a7eadd44f7861d09915b1e841c809bf8..563c7662de62c38594e3c02c99ba19e02d11a324 100644 (file)
@@ -2005,7 +2005,7 @@ class NonHomogeneousTestCase(common.TempFileMixin, TestCase):
         """Test for creation of non-homogeneous arrays."""
 
         # This checks ticket #12.
-        self.assertRaises(ValueError,
+        self.assertRaises((ValueError, TypeError),
                           self.h5file.create_array, '/', 'test', [1, [2, 3]])
         self.assertRaises(NoSuchNodeError, self.h5file.remove_node, '/test')
 
index 9cf83fec33f25a4a3c093b37e508ade9275b593b..9e79130aa7536f3c7b377b5f58a928c029cb823c 100644 (file)
@@ -144,14 +144,14 @@ class ExceptionTestCase(TestCase):
             print('\n', '-=' * 30)
             print("Running test for %s" % (self.title))
         a = self.charList
-        with self.assertRaises(ValueError):
+        with self.assertRaises((ValueError, TypeError)):
             WriteRead(self.h5fname, a)
 
     def test01_types(self):
         """Non supported lists object (numerical types)"""
 
         a = self.numericalList
-        with self.assertRaises(ValueError):
+        with self.assertRaises((ValueError, TypeError)):
             WriteRead(self.h5fname, a)