You are viewing a plain text version of this content. The canonical link for it is here.
Posted to jira@arrow.apache.org by "Joris Van den Bossche (Jira)" <ji...@apache.org> on 2020/09/15 14:30:00 UTC

[jira] [Commented] (ARROW-9993) [Python] Tzinfo - string roundtrip fails on pytz.StaticTzInfo objects

    [ https://issues.apache.org/jira/browse/ARROW-9993?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=17196191#comment-17196191 ] 

Joris Van den Bossche commented on ARROW-9993:
----------------------------------------------

Note that there are other timezones that won't roundtrip completely "faithfully" as well, because we don't keep track of the original python class/library that was used. Eg we tend to prefer pytz, so a datetime.timezone gets becomes a pytz timezone on roundtrip:

{code}
In [10]: import datetime

In [11]: tz = datetime.timezone(datetime.timedelta(hours=1))

In [12]: print(tz)
UTC+01:00

In [13]: pa.lib.tzinfo_to_string(tz)
Out[13]: '+01:00'

In [14]: roundtripped = pa.lib.string_to_tzinfo(pa.lib.tzinfo_to_string(tz))

In [15]: roundtripped
Out[15]: pytz.FixedOffset(60)

In [16]: tz == roundtripped
Out[16]: False
{code}



> [Python] Tzinfo - string roundtrip fails on pytz.StaticTzInfo objects
> ---------------------------------------------------------------------
>
>                 Key: ARROW-9993
>                 URL: https://issues.apache.org/jira/browse/ARROW-9993
>             Project: Apache Arrow
>          Issue Type: Bug
>          Components: Python
>            Reporter: Krisztian Szucs
>            Assignee: Krisztian Szucs
>            Priority: Major
>
> Timezone roundtrip fails with {{pytz.StaticTzInfo}} objects on master:
> {code:python}
> tz = pytz.timezone('Etc/GMT+1')
> pa.lib.string_to_tzinfo(pa.lib.tzinfo_to_string(tz))
> {code}
> {code}
> ---------------------------------------------------------------------------
> UnknownTimeZoneError                      Traceback (most recent call last)
> <ipython-input-4-b890180b2fad> in <module>
> ----> 1 pa.lib.string_to_tzinfo(pa.lib.tzinfo_to_string(tz))
> ~/Workspace/arrow/python/pyarrow/types.pxi in pyarrow.lib.string_to_tzinfo()
>    1838         Time zone object
>    1839     """
> -> 1840     cdef PyObject* tz = GetResultValue(StringToTzinfo(name.encode('utf-8')))
>    1841     return PyObject_to_object(tz)
>    1842
> ~/Workspace/arrow/python/pyarrow/error.pxi in pyarrow.lib.pyarrow_internal_check_status()
>     120 cdef api int pyarrow_internal_check_status(const CStatus& status) \
>     121         nogil except -1:
> --> 122     return check_status(status)
> ~/.conda/envs/arrow38/lib/python3.8/site-packages/pytz/__init__.py in timezone(zone)
>     179                 fp.close()
>     180         else:
> --> 181             raise UnknownTimeZoneError(zone)
>     182
>     183     return _tzinfo_cache[zone]
> UnknownTimeZoneError: '-01'
> {code}



--
This message was sent by Atlassian Jira
(v8.3.4#803005)