From 564aaa0c9e64f415bae0eb7ec3aa4edda1ffc9a6 Mon Sep 17 00:00:00 2001 From: jbrockmendel Date: Sun, 8 Sep 2019 16:27:47 -0700 Subject: [PATCH 1/2] CLN: catch stricter in json --- pandas/io/json/_json.py | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/pandas/io/json/_json.py b/pandas/io/json/_json.py index 4af362d8343f2..32fe6c199d2cb 100644 --- a/pandas/io/json/_json.py +++ b/pandas/io/json/_json.py @@ -974,7 +974,10 @@ def _try_convert_to_date(self, data): new_data = to_datetime(new_data, errors="raise", unit=date_unit) except ValueError: continue - except Exception: + except OverflowError: + # TODO: Why would this be treated different from ValueError? + # In the one test where this is hit, continuing instead of + # breaking doesn't make the test fail break return new_data, True return data, False From 45ac614a5d3a3174ab0fb9eb937ec97079622875 Mon Sep 17 00:00:00 2001 From: jbrockmendel Date: Mon, 9 Sep 2019 11:28:52 -0700 Subject: [PATCH 2/2] continue on OverflowError --- pandas/io/json/_json.py | 7 +------ 1 file changed, 1 insertion(+), 6 deletions(-) diff --git a/pandas/io/json/_json.py b/pandas/io/json/_json.py index 32fe6c199d2cb..b04e540ef81eb 100644 --- a/pandas/io/json/_json.py +++ b/pandas/io/json/_json.py @@ -972,13 +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): continue - except OverflowError: - # TODO: Why would this be treated different from ValueError? - # In the one test where this is hit, continuing instead of - # breaking doesn't make the test fail - break return new_data, True return data, False