Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

STYLE: Added explicit exceptions #22907

Merged
merged 7 commits into from
Oct 1, 2018
Merged
Show file tree
Hide file tree
Changes from 6 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 4 additions & 4 deletions pandas/compat/pickle_compat.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -44,7 +44,7 @@ def load_reduce(self):
try:
stack[-1] = func(*args)
return
except:
except TypeError:
pass

# unknown exception, re-raise
Expand Down Expand Up @@ -182,7 +182,7 @@ def load_newobj_ex(self):

try:
Unpickler.dispatch[pkl.NEWOBJ_EX[0]] = load_newobj_ex
except:
except (AttributeError, KeyError):
pass


Expand Down Expand Up @@ -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
6 changes: 3 additions & 3 deletions pandas/tseries/holiday.py
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand Down Expand Up @@ -426,7 +426,7 @@ def merge_class(base, other):
"""
try:
other = other.rules
except:
except AttributeError:
pass

if not isinstance(other, list):
Expand All @@ -435,7 +435,7 @@ def merge_class(base, other):

try:
base = base.rules
except:
except AttributeError:
pass

if not isinstance(base, list):
Expand Down
6 changes: 3 additions & 3 deletions pandas/util/_print_versions.py
Original file line number Diff line number Diff line change
Expand Up @@ -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:
Expand Down Expand Up @@ -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
Expand Down Expand Up @@ -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 ModuleNotFoundError:
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Great PR. ModuleNotFoundError is Python 3 only, and unfortunately we need to support Python 2 few more months. Can you find a Python 2 compatible way for this please?

deps_blob.append((modname, None))

if (as_json):
Expand Down
2 changes: 1 addition & 1 deletion pandas/util/_validators.py
Original file line number Diff line number Diff line change
Expand Up @@ -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:
Expand Down