Skip to content

REF: avoid catching and re-raising in datetime parsing #50629

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
Jan 9, 2023

Conversation

jbrockmendel
Copy link
Member

Broken off from a branch re-using _convert_str_to_tsobject in array_to_datetime cc @MarcoGorelli

@gfyoung gfyoung added Refactor Internal refactoring of code datetime.date stdlib datetime.date support labels Jan 8, 2023
@MarcoGorelli MarcoGorelli self-requested a review January 8, 2023 09:26
@MarcoGorelli MarcoGorelli added this to the 2.0 milestone Jan 9, 2023
Copy link
Member

@MarcoGorelli MarcoGorelli left a comment

Choose a reason for hiding this comment

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

Nice one! thanks @jbrockmendel

dt = parse_datetime_string(
ts, dayfirst=dayfirst, yearfirst=yearfirst
)
except (ValueError, OverflowError) as err:
raise ValueError("could not convert string to Timestamp") from err
except ValueError as err:
Copy link
Member

Choose a reason for hiding this comment

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

looks like there was no test which hit the OverflowError anyway, nice

Comment on lines -549 to -551
except ValueError:
# Fall through to parse_datetime_string
pass
Copy link
Member

Choose a reason for hiding this comment

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

looks like this was uncovered, so OK to remove

@MarcoGorelli MarcoGorelli merged commit c2b2a49 into pandas-dev:main Jan 9, 2023
@jbrockmendel jbrockmendel deleted the ref-dont_catch branch January 9, 2023 20:15
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
datetime.date stdlib datetime.date support Refactor Internal refactoring of code
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants