diff --git a/examples/units/basic_units.py b/examples/units/basic_units.py index ffc1222e4381..4f8b514e0de5 100644 --- a/examples/units/basic_units.py +++ b/examples/units/basic_units.py @@ -87,7 +87,7 @@ def __call__(self, *args): if hasattr(a, 'convert_to'): try: a = a.convert_to(self.unit) - except: + except Exception: pass arg_units.append(a.get_unit()) converted_args.append(a.get_value()) diff --git a/lib/matplotlib/artist.py b/lib/matplotlib/artist.py index abf330bc1b3c..bb7316d47799 100644 --- a/lib/matplotlib/artist.py +++ b/lib/matplotlib/artist.py @@ -381,7 +381,7 @@ def hitlist(self, event): hascursor, info = self.contains(event) if hascursor: L.append(self) - except: + except Exception: import traceback traceback.print_exc() print("while checking", self.__class__) @@ -1437,7 +1437,7 @@ def properties(self): with warnings.catch_warnings(): warnings.simplefilter('ignore') val = func() - except: + except Exception: continue else: d[name[4:]] = val diff --git a/lib/matplotlib/axis.py b/lib/matplotlib/axis.py index 386185bb9efe..57b5fe656daf 100644 --- a/lib/matplotlib/axis.py +++ b/lib/matplotlib/axis.py @@ -1077,7 +1077,7 @@ def _update_ticks(self, renderer): try: ds1 = self._get_pixel_distance_along_axis( interval_expanded[0], -0.5) - except: + except Exception: warnings.warn("Unable to find pixel distance along axis " "for interval padding of ticks; assuming no " "interval padding needed.") @@ -1087,7 +1087,7 @@ def _update_ticks(self, renderer): try: ds2 = self._get_pixel_distance_along_axis( interval_expanded[1], +0.5) - except: + except Exception: warnings.warn("Unable to find pixel distance along axis " "for interval padding of ticks; assuming no " "interval padding needed.") diff --git a/lib/matplotlib/backend_bases.py b/lib/matplotlib/backend_bases.py index 82493315a625..a39b0afccc3a 100644 --- a/lib/matplotlib/backend_bases.py +++ b/lib/matplotlib/backend_bases.py @@ -1407,7 +1407,7 @@ def _update_enter_leave(self): try: if last.inaxes is not None: last.canvas.callbacks.process('axes_leave_event', last) - except: + except Exception: pass # See ticket 2901582. # I think this is a valid exception to the rule diff --git a/lib/matplotlib/backends/backend_pgf.py b/lib/matplotlib/backends/backend_pgf.py index b0d72b5ddf13..c989d38ddbb5 100644 --- a/lib/matplotlib/backends/backend_pgf.py +++ b/lib/matplotlib/backends/backend_pgf.py @@ -357,7 +357,7 @@ def get_width_height_descent(self, text, prop): # parse metrics from the answer string try: width, height, offset = answer.splitlines()[0].split(",") - except: + except Exception: raise ValueError("Error processing '{}'\nLaTeX Output:\n{}" .format(text, answer)) w, h, o = float(width[:-2]), float(height[:-2]), float(offset[:-2]) diff --git a/lib/matplotlib/cbook/__init__.py b/lib/matplotlib/cbook/__init__.py index 3debb61c08ee..bbc77d9578cd 100644 --- a/lib/matplotlib/cbook/__init__.py +++ b/lib/matplotlib/cbook/__init__.py @@ -1049,7 +1049,7 @@ def delete_masked_points(*args): mask = np.isfinite(xd) if isinstance(mask, np.ndarray): masks.append(mask) - except: # Fixme: put in tuple of possible exceptions? + except Exception: # Fixme: put in tuple of possible exceptions? pass if len(masks): mask = np.logical_and.reduce(masks) diff --git a/lib/matplotlib/mlab.py b/lib/matplotlib/mlab.py index 18754c64a789..717112844a61 100644 --- a/lib/matplotlib/mlab.py +++ b/lib/matplotlib/mlab.py @@ -3032,7 +3032,7 @@ def get_type(item, atype=int): tdict = {None: int, int: float, float: str} try: atype(str(item)) - except: + except Exception: return get_type(item, tdict[atype]) return atype diff --git a/lib/matplotlib/testing/decorators.py b/lib/matplotlib/testing/decorators.py index 85b8d5e87d6b..cddb910e12fa 100644 --- a/lib/matplotlib/testing/decorators.py +++ b/lib/matplotlib/testing/decorators.py @@ -497,7 +497,7 @@ def skip_if_command_unavailable(cmd): from subprocess import check_output try: check_output(cmd) - except: + except Exception: import pytest return pytest.mark.skip(reason='missing command: %s' % cmd[0]) diff --git a/setupext.py b/setupext.py index 9ff35cd9f095..0f1128e3c548 100644 --- a/setupext.py +++ b/setupext.py @@ -1009,7 +1009,7 @@ def do_custom_build(self): try: tarball_cache_dir = _get_xdg_cache_dir() tarball_cache_path = os.path.join(tarball_cache_dir, tarball) - except: + except Exception: # again, do not really care if this fails tarball_cache_dir = None tarball_cache_path = None @@ -1640,5 +1640,5 @@ def get_config(cls): """ try: return config.getboolean(cls.config_category, cls.name) - except: + except Exception: return False # <-- default diff --git a/tools/visualize_tests.py b/tools/visualize_tests.py index 539dd4db2eb4..7786a232f09f 100644 --- a/tools/visualize_tests.py +++ b/tools/visualize_tests.py @@ -122,7 +122,7 @@ def run(show_browser=True): try: import webbrowser webbrowser.open(index) - except: + except Exception: show_message = True if show_message: