O365 / python-o365

A simple python library to interact with Microsoft Graph and Office 365 API
Apache License 2.0
1.6k stars 411 forks source link

Fix broken references to iana_tz.zone in windows_tz.py #1045

Closed Invincibear closed 5 months ago

Invincibear commented 5 months ago

This diff replaces broken iana_tz.zone references with working references to iana_tz.key, per the suggestion of @topcats in this comment. This resolved the 'ZoneInfo object has no attribute Zone' exception I was getting on my end.

This should resolve the following issues:

RogerSelwyn commented 5 months ago

This only works if you do not pass a timezone in on your account setup call: account = Account(credentials, token_backend=token_backend).

If you do the following it will fail: account = Account(credentials, token_backend=token_backend, timezone="UTC") or account = Account(credentials, token_backend=token_backend, timezone=timezone.utc)

With the first call it will fail at line 100 of connection.py as noted in my first post on the linked issue, with the second call it will fail with missing 'key' value because the key is only available when you make the call to get_localzone() at line 102 of connection.py.

It will also fail in utils.py when you go to create a date to be sent to O365 in _build_time_time_zone which also references zone.

I was coming here to create a PR based on my last post on https://github.com/O365/python-o365/issues/1011. As noted there, it doesn't solve the issue in line 100 in connection.py, I'm not sure how that ever worked for the person who changed it in relation to the pytz removal.

Invincibear commented 5 months ago

Let's put this on hold until I can devote a few minutes to working this out

alejcas commented 5 months ago

This should be fixed in fd97b0fc8d2575c59e4e24585a9d3a7330d5e4e7

Please see #1051, a big change on date time timezone handling is coming