Skip to content
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
4 changes: 1 addition & 3 deletions pandas/io/json/_json.py
Original file line number Diff line number Diff line change
Expand Up @@ -972,10 +972,8 @@ def _try_convert_to_date(self, data):
for date_unit in date_units:
try:
new_data = to_datetime(new_data, errors="raise", unit=date_unit)
except ValueError:
except (ValueError, OverflowError):
Copy link
Member

Choose a reason for hiding this comment

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

Actually should we be catching an OutOfBoundsDatetime exception here? Not sure if test coverage is hitting that but I think easy enough to trigger (just try a date like "9999-01-01")

Out of curiosity what causes the OverflowError?

Copy link
Member Author

Choose a reason for hiding this comment

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

I think it is cast_to_unit being called inside array_to_datetime, but would have to check.

OutOfBoundsDatetime subclasses ValueError so that is already caught.

continue
except Exception:
break
return new_data, True
return data, False

Expand Down