Skip to content

Commit 886e035

Browse files
committed
1 parent c733317 commit 886e035

File tree

1 file changed

+12
-13
lines changed

1 file changed

+12
-13
lines changed

pandas/_libs/tslibs/parsing.pyx

+12-13
Original file line numberDiff line numberDiff line change
@@ -3,17 +3,15 @@ Parsing functions for datetime and datetime-like strings.
33
"""
44
import re
55
import time
6-
from io import StringIO
76

87
from libc.string cimport strchr
98

109
import cython
1110
from cython import Py_ssize_t
1211

1312
from cpython.object cimport PyObject_Str
14-
from cpython.unicode cimport PyUnicode_Join
1513

16-
from cpython.datetime cimport datetime, datetime_new, import_datetime
14+
from cpython.datetime cimport datetime, datetime_new, import_datetime, tzinfo
1715
from cpython.version cimport PY_VERSION_HEX
1816
import_datetime()
1917

@@ -475,15 +473,14 @@ cdef dateutil_parse(str timestr, object default, ignoretz=False,
475473
""" lifted from dateutil to get resolution"""
476474

477475
cdef:
478-
object fobj, res, attr, ret, tzdata
476+
object res, attr, ret, tzdata
479477
object reso = None
480478
dict repl = {}
481479

482-
fobj = StringIO(str(timestr))
483-
res = DEFAULTPARSER._parse(fobj, dayfirst=dayfirst, yearfirst=yearfirst)
480+
res = DEFAULTPARSER._parse(timestr, dayfirst=dayfirst, yearfirst=yearfirst)
484481

485482
# dateutil 2.2 compat
486-
if isinstance(res, tuple): # PyTuple_Check
483+
if isinstance(res, tuple):
487484
res, _ = res
488485

489486
if res is None:
@@ -510,20 +507,22 @@ cdef dateutil_parse(str timestr, object default, ignoretz=False,
510507
ret = ret + relativedelta.relativedelta(weekday=res.weekday)
511508
if not ignoretz:
512509
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
513512
if callable(tzinfos):
514513
tzdata = tzinfos(res.tzname, res.tzoffset)
515514
else:
516515
tzdata = tzinfos.get(res.tzname)
517-
if isinstance(tzdata, datetime.tzinfo):
518-
tzinfo = tzdata
516+
if isinstance(tzdata, tzinfo):
517+
new_tzinfo = tzdata
519518
elif isinstance(tzdata, str):
520-
tzinfo = _dateutil_tzstr(tzdata)
519+
new_tzinfo = _dateutil_tzstr(tzdata)
521520
elif isinstance(tzdata, int):
522-
tzinfo = tzoffset(res.tzname, tzdata)
521+
new_tzinfo = tzoffset(res.tzname, tzdata)
523522
else:
524523
raise ValueError("offset must be tzinfo subclass, "
525524
"tz string, or int offset")
526-
ret = ret.replace(tzinfo=tzinfo)
525+
ret = ret.replace(tzinfo=new_tzinfo)
527526
elif res.tzname and res.tzname in time.tzname:
528527
ret = ret.replace(tzinfo=_dateutil_tzlocal())
529528
elif res.tzoffset == 0:
@@ -986,6 +985,6 @@ def _concat_date_cols(tuple date_cols, bint keep_trivial_numbers=True):
986985
item = PyArray_GETITEM(array, PyArray_ITER_DATA(it))
987986
list_to_join[col_idx] = convert_to_unicode(item, False)
988987
PyArray_ITER_NEXT(it)
989-
result_view[row_idx] = PyUnicode_Join(' ', list_to_join)
988+
result_view[row_idx] = " ".join(list_to_join)
990989

991990
return result

0 commit comments

Comments
 (0)