[d-feet/enable-gitlab-ci: 3/6] Remove bare 'except:' clauses



commit f5bfec6d228754a53f2a8eb547e7675da09d7ede
Author: Will Thompson <will willthompson co uk>
Date:   Wed Sep 19 11:02:10 2018 +0100

    Remove bare 'except:' clauses
    
    These are considered Bad Style, and pycodestyle reports them as such.

 src/dfeet/bus_watch.py     | 4 ++--
 src/dfeet/dbus_utils.py    | 4 ++--
 src/dfeet/introspection.py | 6 +++---
 src/dfeet/settings.py      | 2 +-
 src/dfeet/wnck_utils.py    | 6 +++++-
 5 files changed, 13 insertions(+), 9 deletions(-)
---
diff --git a/src/dfeet/bus_watch.py b/src/dfeet/bus_watch.py
index 915d108..b8f5e5e 100644
--- a/src/dfeet/bus_watch.py
+++ b/src/dfeet/bus_watch.py
@@ -106,7 +106,7 @@ class BusNameBox(Gtk.VBox):
         self.__process_id = process_id_new
         try:
             self.__update_command_line()
-        except:
+        except OSError:
             self.__command_line = ''
         # update the shown widget
         self.__update_widget()
@@ -190,7 +190,7 @@ class BusWatch(object):
 
         try:
             del(self.__addr_info)
-        except:
+        except AttributeError:
             pass
 
         # get the selected busname
diff --git a/src/dfeet/dbus_utils.py b/src/dfeet/dbus_utils.py
index 381d1c1..163b658 100644
--- a/src/dfeet/dbus_utils.py
+++ b/src/dfeet/dbus_utils.py
@@ -11,7 +11,7 @@ def convert_complex_type(subsig):
     c_lookahead = ''
     try:
         c_lookahead = subsig[1]
-    except:
+    except IndexError:
         c_lookahead = ''
 
     if c == 'a' and c_lookahead == '{':  # handle dicts as a special case array
@@ -145,7 +145,7 @@ def type_list_to_string(type_list):
 
             try:
                 result += dbus_type
-            except:
+            except Exception:
                 print(type_list)
 
     return result[2:]
diff --git a/src/dfeet/introspection.py b/src/dfeet/introspection.py
index 22f3905..fd41b92 100644
--- a/src/dfeet/introspection.py
+++ b/src/dfeet/introspection.py
@@ -22,7 +22,7 @@ class AddressInfo():
     def __del__(self):
         try:
             self.connection.close()
-        except:
+        except GLib.GError:
             pass
 
     def __init__(self, data_dir, address, name, unique_name, connection_is_bus=True):
@@ -267,7 +267,7 @@ class AddressInfo():
         """callback when the GetConnectionStats dbus function call finished"""
         try:
             res = connection.call_finish(result_async)
-        except:
+        except GLib.GError:
             # The stats interface might not be enabled. Ignore.
             pass
         else:
@@ -279,7 +279,7 @@ class AddressInfo():
         """callback when the GetAllMatchRules dbus function call finished"""
         try:
             res = connection.call_finish(result_async)
-        except:
+        except GLib.GError:
             # The stats interface might not be enabled. Ignore.
             pass
         else:
diff --git a/src/dfeet/settings.py b/src/dfeet/settings.py
index f521ab0..ffd5f29 100644
--- a/src/dfeet/settings.py
+++ b/src/dfeet/settings.py
@@ -7,7 +7,7 @@
 try:
     # python2.x
     import ConfigParser as configparser
-except:
+except ImportError:
     # python3
     import configparser
 import os
diff --git a/src/dfeet/wnck_utils.py b/src/dfeet/wnck_utils.py
index ef3a474..91d91cd 100644
--- a/src/dfeet/wnck_utils.py
+++ b/src/dfeet/wnck_utils.py
@@ -18,7 +18,11 @@ try:
     gi.require_version('Wnck', '3.0')
     from gi.repository import Wnck
     has_libwnck = True
-except:
+except (
+    GLib.Error,  # us
+    ValueError,  # gi.require_version
+    ImportError,  # from gi.repository import Wnck
+):
     has_libwnck = False
 
 


[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]