From d70667c56f52b6e6b6757665a5a059dc01ea7646 Mon Sep 17 00:00:00 2001
From: Giovanni Bussi <giovanni.bussi@gmail.com>
Date: Sat, 30 Mar 2019 08:49:53 +0100
Subject: [PATCH] Fixed python except statements

`except:` might catch the wrong exception by mistake
---
 python/plumed.pyx | 2 +-
 python/setup.py   | 6 +++---
 2 files changed, 4 insertions(+), 4 deletions(-)

diff --git a/python/plumed.pyx b/python/plumed.pyx
index a9b9fc076..e71761636 100644
--- a/python/plumed.pyx
+++ b/python/plumed.pyx
@@ -32,7 +32,7 @@ import array
 try:
      import numpy as np
      HAS_NUMPY=True
-except:
+except ImportError:
      HAS_NUMPY=False
 
 cdef class Plumed:
diff --git a/python/setup.py b/python/setup.py
index 929c3af12..45a824491 100644
--- a/python/setup.py
+++ b/python/setup.py
@@ -79,7 +79,7 @@ def readme():
 
 try:
     include_dirs=[os.environ["plumed_include_dir"]]
-except:
+except KeyError:
     include_dirs=["."]
 
 # allow one to force using cython with env var plumed_force_cython=yes
@@ -88,7 +88,7 @@ try:
     if(os.environ["plumed_force_cython"]=="yes"):
         print('plumed_force_cython=yes')
         USE_CYTHON = True
-except:
+except KeyError:
     pass
 
 # if plumed.cpp is available, do not need cython
@@ -103,7 +103,7 @@ if USE_CYTHON:
         print('importing cython')
         from Cython.Build import cythonize
         extension="pyx"
-    except:
+    except ImportError:
         print('Error: building ' + plumedname + ' requires cython. Please install it first with pip install cython')
         sys.exit(-1)
 else:
-- 
GitLab