@@ -3,17 +3,15 @@ Parsing functions for datetime and datetime-like strings.
3
3
"""
4
4
import re
5
5
import time
6
- from io import StringIO
7
6
8
7
from libc.string cimport strchr
9
8
10
9
import cython
11
10
from cython import Py_ssize_t
12
11
13
12
from cpython.object cimport PyObject_Str
14
- from cpython.unicode cimport PyUnicode_Join
15
13
16
- from cpython.datetime cimport datetime, datetime_new, import_datetime
14
+ from cpython.datetime cimport datetime, datetime_new, import_datetime, tzinfo
17
15
from cpython.version cimport PY_VERSION_HEX
18
16
import_datetime()
19
17
@@ -475,15 +473,14 @@ cdef dateutil_parse(str timestr, object default, ignoretz=False,
475
473
""" lifted from dateutil to get resolution"""
476
474
477
475
cdef:
478
- object fobj, res, attr, ret, tzdata
476
+ object res, attr, ret, tzdata
479
477
object reso = None
480
478
dict repl = {}
481
479
482
- fobj = StringIO(str (timestr))
483
- res = DEFAULTPARSER._parse(fobj, dayfirst = dayfirst, yearfirst = yearfirst)
480
+ res = DEFAULTPARSER._parse(timestr, dayfirst = dayfirst, yearfirst = yearfirst)
484
481
485
482
# dateutil 2.2 compat
486
- if isinstance (res, tuple ): # PyTuple_Check
483
+ if isinstance (res, tuple ):
487
484
res, _ = res
488
485
489
486
if res is None :
@@ -510,20 +507,22 @@ cdef dateutil_parse(str timestr, object default, ignoretz=False,
510
507
ret = ret + relativedelta.relativedelta(weekday = res.weekday)
511
508
if not ignoretz:
512
509
if callable (tzinfos) or tzinfos and res.tzname in tzinfos:
510
+ # Note: as of 1.0 this is not reached because
511
+ # we never pass tzinfos, see GH#22234
513
512
if callable (tzinfos):
514
513
tzdata = tzinfos(res.tzname, res.tzoffset)
515
514
else :
516
515
tzdata = tzinfos.get(res.tzname)
517
- if isinstance (tzdata, datetime. tzinfo):
518
- tzinfo = tzdata
516
+ if isinstance (tzdata, tzinfo):
517
+ new_tzinfo = tzdata
519
518
elif isinstance (tzdata, str ):
520
- tzinfo = _dateutil_tzstr(tzdata)
519
+ new_tzinfo = _dateutil_tzstr(tzdata)
521
520
elif isinstance (tzdata, int ):
522
- tzinfo = tzoffset(res.tzname, tzdata)
521
+ new_tzinfo = tzoffset(res.tzname, tzdata)
523
522
else :
524
523
raise ValueError (" offset must be tzinfo subclass, "
525
524
" tz string, or int offset" )
526
- ret = ret.replace(tzinfo = tzinfo )
525
+ ret = ret.replace(tzinfo = new_tzinfo )
527
526
elif res.tzname and res.tzname in time.tzname:
528
527
ret = ret.replace(tzinfo = _dateutil_tzlocal())
529
528
elif res.tzoffset == 0 :
@@ -986,6 +985,6 @@ def _concat_date_cols(tuple date_cols, bint keep_trivial_numbers=True):
986
985
item = PyArray_GETITEM(array, PyArray_ITER_DATA(it))
987
986
list_to_join[col_idx] = convert_to_unicode(item, False )
988
987
PyArray_ITER_NEXT(it)
989
- result_view[row_idx] = PyUnicode_Join( ' ' , list_to_join)
988
+ result_view[row_idx] = " " .join( list_to_join)
990
989
991
990
return result
0 commit comments