8000 Merge pull request #11995 from timhoffm/bare-except · matplotlib/matplotlib@90037f4 · GitHub
[go: up one dir, main page]

Skip to content

Commit 90037f4

Browse files
authored
Merge pull request #11995 from timhoffm/bare-except
Don't use bare except statements
2 parents c582745 + 97471f4 commit 90037f4

File tree

10 files changed

+13
-13
lines changed

10 files changed

+13
-13
lines changed

examples/units/basic_units.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -87,7 +87,7 @@ def __call__(self, *args):
8787
if hasattr(a, 'convert_to'):
8888
try:
8989
a = a.convert_to(self.unit)
90-
except:
90+
except Exception:
9191
pass
9292
arg_units.append(a.get_unit())
9393
converted_args.append(a.get_value())

lib/matplotlib/artist.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -381,7 +381,7 @@ def hitlist(self, event):
381381
hascursor, info = self.contains(event)
382382
if hascursor:
383383
L.append(self)
384-
except:
384+
except Exception:
385385
import traceback
386386
traceback.print_exc()
387387
print("while checking", self.__class__)
@@ -1437,7 +1437,7 @@ def properties(self):
14371437
with warnings.catch_warnings():
14381438
warnings.simplefilter('ignore')
14391439
val = func()
1440-
except:
1440+
except Exception:
14411441
continue
14421442
else:
14431443
d[name[4:]] = val

lib/matplotlib/axis.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1077,7 +1077,7 @@ def _update_ticks(self, renderer):
10771077
try:
10781078
ds1 = self._get_pixel_distance_along_axis(
10791079
interval_expanded[0], -0.5)
1080-
except:
1080+
except Exception:
10811081
warnings.warn("Unable to find pixel distance along axis "
10821082
"for interval padding of ticks; assuming no "
10831083
"interval padding needed.")
@@ -1087,7 +1087,7 @@ def _update_ticks(self, renderer):
10871087
try:
10881088
ds2 = self._get_pixel_distance_along_axis(
10891089
interval_expanded[1], +0.5)
1090-
except:
1090+
except Exception:
10911091
warnings.warn("Unable to find pixel distance along axis "
10921092
"for interval padding of ticks; assuming no "
10931093
"interval padding needed.")

lib/matplotlib/backend_bases.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1407,7 +1407,7 @@ def _update_enter_leave(self):
14071407
try:
14081408
if last.inaxes is not None:
14091409
last.canvas.callbacks.process('axes_leave_event', last)
1410-
except:
1410+
except Exception:
14111411
pass
14121412
# See ticket 2901582.
14131413
# I think this is a valid exception to the rule

lib/matplotlib/backends/backend_pgf.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -357,7 +357,7 @@ def get_width_height_descent(self, text, prop):
357357
# parse metrics from the answer string
358358
try:
359359
width, height, offset = answer.splitlines()[0].split(",")
360-
except:
360+
except Exception:
361361
raise ValueError("Error processing '{}'\nLaTeX Output:\n{}"
362362
.format(text, answer))
363363
w, h, o = float(width[:-2]), float(height[:-2]), float(offset[:-2])

lib/matplotlib/cbook/__init__.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1049,7 +1049,7 @@ def delete_masked_points(*args):
10491049
mask = np.isfinite(xd)
10501050
if isinstance(mask, np.ndarray):
10511051
masks.append(mask)
1052-
except: # Fixme: put in tuple of possible exceptions?
1052+
except Exception: # Fixme: put in tuple of possible exceptions?
10531053
pass
10541054
if len(masks):
10551055
mask = np.logical_and.reduce(masks)

lib/matplotlib/mlab.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3032,7 +3032,7 @@ def get_type(item, atype=int):
30323032
tdict = {None: int, int: float, float: str}
30333033
try:
30343034
atype(str(item))
3035-
except:
3035+
except Exception:
30363036
return get_type(item, tdict[atype])
30373037
return atype
30383038

lib/matplotlib/testing/decorators.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -497,7 +497,7 @@ def skip_if_command_unavailable(cmd):
497497
from subprocess import check_output
498498
try:
499499
check_output(cmd)
500-
except:
500+
except Exception:
501501
import pytest
502502
return pytest.mark.skip(reason='missing command: %s' % cmd[0])
503503

setupext.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1009,7 +1009,7 @@ def do_custom_build(self):
10091009
try:
10101010
tarball_cache_dir = _get_xdg_cache_dir()
10111011
tarball_cache_path = os.path.join(tarball_cache_dir, tarball)
1012-
except:
1012+
except Exception:
10131013
# again, do not really care if this fails
10141014
tarball_cache_dir = None
10151015
tarball_cache_path = None
@@ -1640,5 +1640,5 @@ def get_config(cls):
16401640
"""
16411641
try:
16421642
return config.getboolean(cls.config_category, cls.name)
1643-
except:
1643+
except Exception:
16441644
return False # <-- default

tools/visualize_tests.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -122,7 +122,7 @@ def run(show_browser=True):
122122
try:
123123
import webbrowser
124124
webbrowser.open(index)
125-
except:
125+
except Exception:
126126
show_message = True
127127

128128
if show_message:

0 commit comments

Comments
 (0)
0