diff options
author | Philipp Hahn <hahn@univention.de> | 2018-11-20 08:59:35 +0100 |
---|---|---|
committer | Daniel Berrange <berrange@redhat.com> | 2020-08-18 09:48:25 +0000 |
commit | 67af8b910b62de6542e15d68c8dd5a275cf77f55 (patch) | |
tree | 4101825690157f8ec1286e3900c1013deec863b3 | |
parent | ec76ba3507597dd3ef4090ce9bfeee7d75b2d9d5 (diff) | |
download | libvirt-python-67af8b910b62de6542e15d68c8dd5a275cf77f55.tar.gz |
override: Simplify exception handling
sys.exc_info() returns a 3-tuple (type, value, traceback), where `value`
is the instance captured by `except type as value`.
Signed-off-by: Philipp Hahn <hahn@univention.de>
-rw-r--r-- | libvirt-override.py | 10 |
1 files changed, 3 insertions, 7 deletions
diff --git a/libvirt-override.py b/libvirt-override.py index 192831e..aeeee52 100644 --- a/libvirt-override.py +++ b/libvirt-override.py @@ -3,17 +3,13 @@ # # On cygwin, the DLL is called cygvirtmod.dll -import sys - try: import libvirtmod -except ImportError: - lib_e = sys.exc_info()[1] +except ImportError as lib_e: try: import cygvirtmod as libvirtmod - except ImportError: - cyg_e = sys.exc_info()[1] - if str(cyg_e).count("No module named"): + except ImportError as cyg_e: + if "No module named" in str(cyg_e): raise lib_e |