Skip to content
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

tzlocal version 3.0 incompatibility #913

Open
r-stiller opened this issue Aug 24, 2021 · 1 comment
Open

tzlocal version 3.0 incompatibility #913

r-stiller opened this issue Aug 24, 2021 · 1 comment

Comments

@r-stiller
Copy link

r-stiller commented Aug 24, 2021

Arctic Version

1.80

Arctic Store

VersionStore

Platform and version

Windows 10 x64 21H1, Intel(R) Xeon(R) CPU E3-1271 v3, 16GB

Description of problem and/or code sample that reproduces the issue

Hello there, i ran into a problem when calling library.list_versions()

---------------------------------------------------------------------------
AttributeError                            Traceback (most recent call last)
<ipython-input-109-bf360df79edb> in <module>()
----> 1 library.list_versions()

C:\ProgramData\Miniconda3\envs\tf\lib\site-packages\arctic\store\version_store.py in list_versions(self, symbol, snapshot, latest_only)
    292                                  'deleted': meta.get('deleted', False) if meta else False,
    293                                  # We return offset-aware datetimes in Local Time.
--> 294                                  'date': ms_to_datetime(datetime_to_ms(version['_id'].generation_time)),
    295                                  'snapshots': [snapshots[s] for s in version.get('parent', []) if s in snapshots]})
    296         return versions

C:\ProgramData\Miniconda3\envs\tf\lib\site-packages\arctic\date\_util.py in ms_to_datetime(ms, tzinfo)
    151 
    152     if tzinfo is None:
--> 153         tzinfo = mktz()
    154 
    155     return datetime.datetime.fromtimestamp(ms * 1e-3, tzinfo)

C:\ProgramData\Miniconda3\envs\tf\lib\site-packages\arctic\date\_mktz.py in mktz(zone)
     31     """
     32     if zone is None:
---> 33         zone = tzlocal.get_localzone().zone
     34     zone = six.u(zone)
     35     tz = dateutil.tz.gettz(zone)

AttributeError: 'backports.zoneinfo.ZoneInfo' object has no attribute 'zone'

After a quick research I noticed that the module tzlocal changed from pytz to zoneinfo (backports.zoneinfo on Python 3.8 or earlier) in version 3.0.

I recommend to either pin the version of tzlocal to <3.0 or do something like

try:
   zone = tzlocal.get_localzone().zone
except AttributeError:
   # The zone attribute is called key in tzlocal >= 3.0
   zone = tzlocal.get_localzone().key
@r-stiller
Copy link
Author

r-stiller commented Nov 9, 2021

tzlocal version 4.0 now uses the pytz_deprecation_shim which restores the behaviour of version 2.0.
It also introduces the get_localzone_name() function which only returns the timezone name.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant