[h5py] 12/455: 1.8 fix for h5i

Ghislain Vaillant ghisvail-guest at moszumanska.debian.org
Thu Jul 2 18:19:12 UTC 2015


This is an automated email from the git hooks/post-receive script.

ghisvail-guest pushed a commit to annotated tag 1.3.0
in repository h5py.

commit ca148ac5aa6aa52e633a6536f42146ce585d92be
Author: andrewcollette <andrew.collette at gmail.com>
Date:   Wed May 7 18:57:24 2008 +0000

    1.8 fix for h5i
---
 h5py/h5i.pyx           | 11 ++++++-----
 h5py/tests/test_h5i.py | 14 ++++++++++++--
 2 files changed, 18 insertions(+), 7 deletions(-)

diff --git a/h5py/h5i.pyx b/h5py/h5i.pyx
index 14efe4d..0d6f81e 100755
--- a/h5py/h5i.pyx
+++ b/h5py/h5i.pyx
@@ -20,7 +20,7 @@ from h5  cimport hid_t
 
 import h5
 from h5 import DDict
-from errors import H5TypeError
+from errors import H5Error
 
 # === Public constants and data structures ====================================
 
@@ -58,15 +58,16 @@ def get_name(hid_t obj_id):
 
         Determine (a) name of an HDF5 object.  Because an object has as many
         names as there are hard links to it, this may not be unique.  If the
-        object does not have a name (transient datatypes, etc.), OR IF THE
-        IDENTIFIER IS INVALID, the  return value is None.  Raises H5Error
-        if there is an internal error.
+        object does not have a name (transient datatypes, etc.), the return
+        value is None.  If the identifier is invalid, raises H5Error.
     """
     cdef size_t namelen
     cdef char* name
 
     namelen = H5Iget_name(obj_id, NULL, 0)
-    if namelen < 0:
+
+    # H5Iget_type call is a workaround for changed behavior 1.6 to 1.8
+    if namelen < 0 or (H5I_BADID == H5Iget_type(obj_id)): 
         raise H5Error("Failed to determine name of object %d" % obj_id)
     if namelen == 0:
         return None
diff --git a/h5py/tests/test_h5i.py b/h5py/tests/test_h5i.py
index e0a44b0..e859b4a 100644
--- a/h5py/tests/test_h5i.py
+++ b/h5py/tests/test_h5i.py
@@ -13,7 +13,7 @@ import unittest
 import os
 
 import h5py
-from h5py import h5f, h5g, h5i
+from h5py import h5f, h5g, h5i, h5t
 from h5py.errors import H5Error
 
 HDFNAME = os.path.join(os.path.dirname(h5py.__file__), 'tests/data/attributes.hdf5')
@@ -36,5 +36,15 @@ class TestH5I(unittest.TestCase):
 
     def test_get_name(self):
         self.assertEqual(h5i.get_name(self.obj), '/Group')
-        self.assertEqual(h5i.get_name(-1), None)
+        self.assertEqual(h5i.get_name(h5t.STD_I8LE), None)
+        self.assertRaises(H5Error, h5i.get_name, -1)
+
+
+
+
+
+
+
+
+
 

-- 
Alioth's /usr/local/bin/git-commit-notice on /srv/git.debian.org/git/debian-science/packages/h5py.git



More information about the debian-science-commits mailing list