From fa204efbf03da9e8aad0b87197ff1eb5b6bd9c6f Mon Sep 17 00:00:00 2001
From: Reinhard Prix <reinhard.prix@aei.mpg.de>
Date: Tue, 23 Jul 2019 16:06:51 +0200
Subject: [PATCH] _optional_import: don't re-raise ImportError exception ever

- any import failure should just be treated as such: we can't import
  that module for whatever reason
---
 pyfstat/tcw_fstat_map_funcs.py | 7 ++-----
 1 file changed, 2 insertions(+), 5 deletions(-)

diff --git a/pyfstat/tcw_fstat_map_funcs.py b/pyfstat/tcw_fstat_map_funcs.py
index e3ef1f3..10ee31f 100644
--- a/pyfstat/tcw_fstat_map_funcs.py
+++ b/pyfstat/tcw_fstat_map_funcs.py
@@ -31,11 +31,8 @@ def _optional_import(modulename, shorthand=None):
         logging.debug("Successfully imported module %s%s." % (modulename, shorthandbit))
         success = True
     except ImportError as e:
-        if e.message == "No module named " + modulename:
-            logging.debug("No module {:s} found.".format(modulename))
-            success = False
-        else:
-            raise
+        logging.debug("Failed to import module {:s}.".format(modulename))
+        success = False
 
     return success
 
-- 
GitLab