Skip to content

Commit b52dda8

Browse files
committed
ERR: fix exception propogation for datetime parsing functions, noted in python 3.6
closes #14561 Author: Jeff Reback <[email protected]> Closes #14678 from jreback/py3.6_fix and squashes the following commits: c8eed83 [Jeff Reback] ERR: fix exception propogation for datetime parsing functions, noted in python 3.6
1 parent b23a329 commit b52dda8

File tree

3 files changed

+7
-6
lines changed

3 files changed

+7
-6
lines changed

doc/source/whatsnew/v0.19.2.txt

+1-1
Original file line numberDiff line numberDiff line change
@@ -38,7 +38,7 @@ Bug Fixes
3838

3939

4040

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

4343

4444

pandas/src/datetime.pxd

+4-4
Original file line numberDiff line numberDiff line change
@@ -126,8 +126,8 @@ cdef extern from "datetime/np_datetime_strings.h":
126126

127127

128128

129-
cdef inline _string_to_dts(object val, pandas_datetimestruct* dts,
130-
int* out_local, int* out_tzoffset):
129+
cdef inline int _string_to_dts(object val, pandas_datetimestruct* dts,
130+
int* out_local, int* out_tzoffset) except? -1:
131131
cdef int result
132132
cdef char *tmp
133133

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

140140
if result == -1:
141141
raise ValueError('Unable to parse %s' % str(val))
142+
return result
142143

143144
cdef inline int _cstring_to_dts(char *val, int length,
144145
pandas_datetimestruct* dts,
145-
int* out_local, int* out_tzoffset):
146+
int* out_local, int* out_tzoffset) except? -1:
146147
cdef:
147148
npy_bool special
148149
PANDAS_DATETIMEUNIT out_bestunit
@@ -195,4 +196,3 @@ cdef inline int64_t _date_to_datetime64(object val,
195196
dts.hour = dts.min = dts.sec = dts.us = 0
196197
dts.ps = dts.as = 0
197198
return pandas_datetimestruct_to_datetime(PANDAS_FR_ns, dts)
198-

setup.py

+2-1
Original file line numberDiff line numberDiff line change
@@ -454,7 +454,8 @@ def pxd(name):
454454

455455
tseries_depends = ['pandas/src/datetime/np_datetime.h',
456456
'pandas/src/datetime/np_datetime_strings.h',
457-
'pandas/src/period_helper.h']
457+
'pandas/src/period_helper.h',
458+
'pandas/src/datetime.pxd']
458459

459460

460461
# some linux distros require it

0 commit comments

Comments
 (0)