diff --git a/pandas/compat/pickle_compat.py b/pandas/compat/pickle_compat.py index c1a9a9fc1ed13..713a5b1120beb 100644 --- a/pandas/compat/pickle_compat.py +++ b/pandas/compat/pickle_compat.py @@ -33,7 +33,7 @@ def load_reduce(self): cls = args[0] stack[-1] = object.__new__(cls) return - except: + except TypeError: pass # try to re-encode the arguments @@ -44,7 +44,7 @@ def load_reduce(self): try: stack[-1] = func(*args) return - except: + except TypeError: pass # unknown exception, re-raise @@ -182,7 +182,7 @@ def load_newobj_ex(self): try: Unpickler.dispatch[pkl.NEWOBJ_EX[0]] = load_newobj_ex -except: +except (AttributeError, KeyError): pass @@ -210,5 +210,5 @@ def load(fh, encoding=None, compat=False, is_verbose=False): up.is_verbose = is_verbose return up.load() - except: + except (ValueError, TypeError): raise diff --git a/pandas/tseries/holiday.py b/pandas/tseries/holiday.py index b9c89c4e314f9..0497a827e2e1b 100644 --- a/pandas/tseries/holiday.py +++ b/pandas/tseries/holiday.py @@ -294,7 +294,7 @@ def _apply_rule(self, dates): def register(cls): try: name = cls.name - except: + except AttributeError: name = cls.__name__ holiday_calendars[name] = cls @@ -426,7 +426,7 @@ def merge_class(base, other): """ try: other = other.rules - except: + except AttributeError: pass if not isinstance(other, list): @@ -435,7 +435,7 @@ def merge_class(base, other): try: base = base.rules - except: + except AttributeError: pass if not isinstance(base, list): diff --git a/pandas/util/_print_versions.py b/pandas/util/_print_versions.py index 5600834f3b615..03fc82a3acef5 100644 --- a/pandas/util/_print_versions.py +++ b/pandas/util/_print_versions.py @@ -21,7 +21,7 @@ def get_sys_info(): stdout=subprocess.PIPE, stderr=subprocess.PIPE) so, serr = pipe.communicate() - except: + except (OSError, ValueError): pass else: if pipe.returncode == 0: @@ -50,7 +50,7 @@ def get_sys_info(): ("LANG", "{lang}".format(lang=os.environ.get('LANG', "None"))), ("LOCALE", '.'.join(map(str, locale.getlocale()))), ]) - except: + except (KeyError, ValueError): pass return blob @@ -108,7 +108,7 @@ def show_versions(as_json=False): mod = importlib.import_module(modname) ver = ver_f(mod) deps_blob.append((modname, ver)) - except: + except ImportError: deps_blob.append((modname, None)) if (as_json): diff --git a/pandas/util/_validators.py b/pandas/util/_validators.py index a96563051e7de..e51e0c88e5b95 100644 --- a/pandas/util/_validators.py +++ b/pandas/util/_validators.py @@ -59,7 +59,7 @@ def _check_for_default_values(fname, arg_val_dict, compat_args): # could not compare them directly, so try comparison # using the 'is' operator - except: + except ValueError: match = (arg_val_dict[key] is compat_args[key]) if not match: