Skip to content

ERR: fix exception propogation for datetime parsing functions, noted in python 3.6 #14678

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

Closed
wants to merge 1 commit into from
Closed
Show file tree
Hide file tree
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
2 changes: 1 addition & 1 deletion doc/source/whatsnew/v0.19.2.txt
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ Bug Fixes




- Bug in not propogating exceptions in parsing invalid datetimes, noted in python 3.6 (:issue:`14561`)



Expand Down
8 changes: 4 additions & 4 deletions pandas/src/datetime.pxd
Original file line number Diff line number Diff line change
Expand Up @@ -126,8 +126,8 @@ cdef extern from "datetime/np_datetime_strings.h":



cdef inline _string_to_dts(object val, pandas_datetimestruct* dts,
int* out_local, int* out_tzoffset):
cdef inline int _string_to_dts(object val, pandas_datetimestruct* dts,
int* out_local, int* out_tzoffset) except? -1:
cdef int result
cdef char *tmp

Expand All @@ -139,10 +139,11 @@ cdef inline _string_to_dts(object val, pandas_datetimestruct* dts,

if result == -1:
raise ValueError('Unable to parse %s' % str(val))
return result

cdef inline int _cstring_to_dts(char *val, int length,
pandas_datetimestruct* dts,
int* out_local, int* out_tzoffset):
int* out_local, int* out_tzoffset) except? -1:
cdef:
npy_bool special
PANDAS_DATETIMEUNIT out_bestunit
Expand Down Expand Up @@ -195,4 +196,3 @@ cdef inline int64_t _date_to_datetime64(object val,
dts.hour = dts.min = dts.sec = dts.us = 0
dts.ps = dts.as = 0
return pandas_datetimestruct_to_datetime(PANDAS_FR_ns, dts)

3 changes: 2 additions & 1 deletion setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -454,7 +454,8 @@ def pxd(name):

tseries_depends = ['pandas/src/datetime/np_datetime.h',
'pandas/src/datetime/np_datetime_strings.h',
'pandas/src/period_helper.h']
'pandas/src/period_helper.h',
'pandas/src/datetime.pxd']


# some linux distros require it
Expand Down