Skip to content

Commit 700e36d

Browse files
jbrockmendelproost
authored andcommitted
CLN: Exception x5 (pandas-dev#28605)
1 parent 1621412 commit 700e36d

File tree

3 files changed

+12
-14
lines changed

3 files changed

+12
-14
lines changed

pandas/_libs/tslibs/conversion.pyx

+1-1
Original file line numberDiff line numberDiff line change
@@ -519,7 +519,7 @@ cdef _TSObject convert_str_to_tsobject(object ts, object tz, object unit,
519519
try:
520520
ts = parse_datetime_string(ts, dayfirst=dayfirst,
521521
yearfirst=yearfirst)
522-
except Exception:
522+
except (ValueError, OverflowError):
523523
raise ValueError("could not convert string to Timestamp")
524524

525525
return convert_to_tsobject(ts, tz, unit, dayfirst, yearfirst)

pandas/_libs/tslibs/parsing.pyx

+2-2
Original file line numberDiff line numberDiff line change
@@ -309,9 +309,9 @@ cdef parse_datetime_string_with_reso(date_string, freq=None, dayfirst=False,
309309
parsed, reso = dateutil_parse(date_string, _DEFAULT_DATETIME,
310310
dayfirst=dayfirst, yearfirst=yearfirst,
311311
ignoretz=False, tzinfos=None)
312-
except Exception as e:
312+
except (ValueError, OverflowError) as err:
313313
# TODO: allow raise of errors within instead
314-
raise DateParseError(e)
314+
raise DateParseError(err)
315315
if parsed is None:
316316
raise DateParseError("Could not parse {dstr}".format(dstr=date_string))
317317
return parsed, parsed, reso

pandas/plotting/_matplotlib/tools.py

+9-11
Original file line numberDiff line numberDiff line change
@@ -281,17 +281,15 @@ def _remove_labels_from_axis(axis):
281281
for t in axis.get_majorticklabels():
282282
t.set_visible(False)
283283

284-
try:
285-
# set_visible will not be effective if
286-
# minor axis has NullLocator and NullFormattor (default)
287-
if isinstance(axis.get_minor_locator(), ticker.NullLocator):
288-
axis.set_minor_locator(ticker.AutoLocator())
289-
if isinstance(axis.get_minor_formatter(), ticker.NullFormatter):
290-
axis.set_minor_formatter(ticker.FormatStrFormatter(""))
291-
for t in axis.get_minorticklabels():
292-
t.set_visible(False)
293-
except Exception: # pragma no cover
294-
raise
284+
# set_visible will not be effective if
285+
# minor axis has NullLocator and NullFormattor (default)
286+
if isinstance(axis.get_minor_locator(), ticker.NullLocator):
287+
axis.set_minor_locator(ticker.AutoLocator())
288+
if isinstance(axis.get_minor_formatter(), ticker.NullFormatter):
289+
axis.set_minor_formatter(ticker.FormatStrFormatter(""))
290+
for t in axis.get_minorticklabels():
291+
t.set_visible(False)
292+
295293
axis.get_label().set_visible(False)
296294

297295

0 commit comments

Comments
 (0)