python: fix all "do not use bare 'except'" warnings
authorSimon Marchi <simon.marchi@efficios.com>
Tue, 27 Aug 2019 04:57:30 +0000 (00:57 -0400)
committerSimon Marchi <simon.marchi@efficios.com>
Tue, 27 Aug 2019 20:23:29 +0000 (16:23 -0400)
I wasn't sure why that mattered, but I found this explanation pretty
good:

  https://help.semmle.com/wiki/pages/viewpage.action?pageId=29394005

In short, we don't want to catch KeyboardInterrupt and SystemExit.

Change-Id: I0ee20f45ac715a0477c867960cfaea511518171f
Signed-off-by: Simon Marchi <simon.marchi@efficios.com>
Reported-by: flake8
Reviewed-on: https://review.lttng.org/c/babeltrace/+/1980
Tested-by: jenkins <jenkins@lttng.org>
src/bindings/python/bt2/bt2/component_descriptor.py
src/bindings/python/bt2/bt2/field.py
src/bindings/python/bt2/bt2/message_iterator.py
src/bindings/python/bt2/bt2/value.py

index 3134886b3d6e9a1e44ab0fc49ddc662f23bc699b..bafba7e5cfeb146e65aaf008deedb3a80c090461 100644 (file)
@@ -31,7 +31,7 @@ def _is_source_comp_cls(comp_cls):
 
     try:
         return issubclass(comp_cls, bt2_component._UserSourceComponent)
-    except:
+    except Exception:
         return False
 
 
@@ -41,7 +41,7 @@ def _is_filter_comp_cls(comp_cls):
 
     try:
         return issubclass(comp_cls, bt2_component._UserFilterComponent)
-    except:
+    except Exception:
         return False
 
 
@@ -51,7 +51,7 @@ def _is_sink_comp_cls(comp_cls):
 
     try:
         return issubclass(comp_cls, bt2_component._UserSinkComponent)
-    except:
+    except Exception:
         return False
 
 
index ecbd9715753ce3e6fcec9d4f36dff19f288abd32..4d31f8fa064517795ba0354399cea18c0301381c 100644 (file)
@@ -141,7 +141,7 @@ class _NumericField(_Field):
     def _spec_eq(self, other):
         try:
             return self._value == self._extract_value(other)
-        except:
+        except Exception:
             return False
 
     def __rmod__(self, other):
@@ -393,7 +393,7 @@ class _StringField(_Field):
     def _spec_eq(self, other):
         try:
             return self._value == self._value_to_str(other)
-        except:
+        except Exception:
             return False
 
     def __lt__(self, other):
index 5895b23735b2a30f343b22bdb3c3ec1fa0754710..5ccec738aad7a1b4cc7c66362cf4ed4c0f59c2fd 100644 (file)
@@ -143,7 +143,7 @@ class _UserMessageIterator(_MessageIterator):
             msg = next(self)
         except StopIteration:
             raise bt2.Stop
-        except:
+        except Exception:
             raise
 
         utils._check_type(msg, bt2_message._Message)
index 3acabe7998ca5eddd6fb788b20c93216c39ff9a1..3001502abb472600a8038d1d056c19197a8c374b 100644 (file)
@@ -132,7 +132,7 @@ class _NumericValue(_Value):
     def __eq__(self, other):
         try:
             return self._value == self._extract_value(other)
-        except:
+        except Exception:
             return False
 
     def __rmod__(self, other):
@@ -383,7 +383,7 @@ class StringValue(collections.abc.Sequence, _Value):
     def __eq__(self, other):
         try:
             return self._value == self._value_to_str(other)
-        except:
+        except Exception:
             return False
 
     def __lt__(self, other):
This page took 0.026604 seconds and 4 git commands to generate.