From 2fe2bf3ddc28874f721d7ab798dc5df377e1bcf2 Mon Sep 17 00:00:00 2001 From: Thomas VINCENT Date: Wed, 23 Nov 2022 14:08:49 +0100 Subject: [PATCH] special case of h5py<2.10 --- src/hdf5plugin/_utils.py | 7 +++++-- src/hdf5plugin/test.py | 2 ++ 2 files changed, 7 insertions(+), 2 deletions(-) diff --git a/src/hdf5plugin/_utils.py b/src/hdf5plugin/_utils.py index 7f3d377c..b7bea1d3 100644 --- a/src/hdf5plugin/_utils.py +++ b/src/hdf5plugin/_utils.py @@ -83,12 +83,15 @@ def register_filter(name): # Unregister existing filter filter_id = FILTERS[name] is_avail = is_filter_available(name) - # TODO h5py>=2.10 + if h5py.version.version_tuple < (2, 10) and is_avail in (True, None): + logger.error( + "h5py.h5z.unregister_filter is not available in this version of h5py.") + return False if is_avail is True: if not h5py.h5z.unregister_filter(filter_id): logger.error("Failed to unregister filter %s (%d)" % (name, filter_id)) return False - elif is_avail is None: # Cannot probe filter availability + if is_avail is None: # Cannot probe filter availability try: h5py.h5z.unregister_filter(filter_id) except RuntimeError: diff --git a/src/hdf5plugin/test.py b/src/hdf5plugin/test.py index e8b14826..df61300e 100644 --- a/src/hdf5plugin/test.py +++ b/src/hdf5plugin/test.py @@ -280,6 +280,7 @@ def _simple_test(self, filter_name): else: self._test(filter_name) + @unittest.skipIf(h5py.version.version_tuple < (2, 10), "h5py<2.10: unregister_filer not available") @unittest.skipUnless(hdf5plugin.config.embedded_filters, "No embedded filters") def test_register_single_filter(self): """Re-register embedded filters one at a time""" @@ -289,6 +290,7 @@ def test_register_single_filter(self): self.assertTrue(status) self._simple_test(filter_name) + @unittest.skipIf(h5py.version.version_tuple < (2, 10), "h5py<2.10: unregister_filer not available") @unittest.skipUnless(hdf5plugin.config.embedded_filters, "No embedded filters") def test_register_all_filters(self): """Re-register embedded filters all at once"""