Skip to content

CLN: avoid catching Exception in generic #28370

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

Merged
merged 1 commit into from
Sep 11, 2019
Merged
Changes from all 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
20 changes: 7 additions & 13 deletions pandas/core/generic.py
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,7 @@
is_datetime64tz_dtype,
is_dict_like,
is_extension_array_dtype,
is_float,
is_integer,
is_list_like,
is_number,
Expand Down Expand Up @@ -1525,16 +1526,12 @@ def __pos__(self):
return self.__array_wrap__(arr)

def __invert__(self):
try:
arr = operator.inv(com.values_from_object(self))
return self.__array_wrap__(arr)
except Exception:

if not self.size:
# inv fails with 0 len
if not np.prod(self.shape):
return self
return self

raise
arr = operator.inv(com.values_from_object(self))
return self.__array_wrap__(arr)

def __nonzero__(self):
raise ValueError(
Expand Down Expand Up @@ -5316,11 +5313,8 @@ def _check_inplace_setting(self, value):
if not self._is_numeric_mixed_type:

# allow an actual np.nan thru
try:
if np.isnan(value):
return True
except Exception:
pass
if is_float(value) and np.isnan(value):
return True

raise TypeError(
"Cannot do inplace boolean setting on "
Expand Down