-
Notifications
You must be signed in to change notification settings - Fork 424
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
PYTZ removal causes errors in latest release #1011
Comments
If it helps, I'm using Python 3.11 on Debian Bookworm. |
Just trying to debug this more. If I pass in UTC as the timezone (which is what get_windows_tz in windows_tz.py) is looking for, then line 100 (or they're about) in connection.py fails. In fact, as setup that line will always fail if it is reached. The If stamens before checks for a string, and if the string is passed to dt.timezone() it then errors.
|
The |
Sorry for many posts, just doing my thoughts. Either it will error in connection.py if you pass in a string, or it will get a warning in windows_tz.py because it accesses the zone attribute, or it will error in windows_tz.py because the passed in timezone has no zone attribute. I don't see anyway to avoid at least a warning. |
I merged a few days ago a PR that dropped pytz from this project. Why is pytz doing there? |
I don't know, it comes from get_localzone() call, which is in tzlocal/unix.py. On my system that is at 4.3.1, I assume installed as part of Python 3.11. Looking at that it is specifically returning something from here 'import pytz_deprecation_shim as pds'. My suspicion would be that it is trying to tell you that you shouldn't be accessing `.zone' any more. I unpacked the single line if statement in here so I could get my head around it, but I suspect the iana_tz.zone needs removing, it is that line that produces the warning:-
|
I've been trying to dig into how you remove that .zone requirement, and I really can't figure it out. If I pass in a dateutil timezone such as I'm lost. |
I think I have a fix, but I'd want others to test it. In connection.py change:
to
In windows_tz.py change:
to
If that works for others, I'll submit the PR. |
Hi, the problem is that tzlocal get_localzone() function uses PyTzDeprecationShim. See #753 |
Fixed 31e997c |
Just looking at this again, since with my latest submission I need to move up a version. I'm still unable to pass in a timezone to my account setup call. I'm making this call: This fails with:
Relevant lines in connection.py are:
100 will always fail with this error, because 99 mandates a string and 100 fails if it is a string. So currently it is impossible to pass in a timezone. |
Trying to debug again. If it pass in a strung timezone I get the initial report error, if I pass in a python timezone or don't pass a timezone, then I get:
I'm assuming it must be something I'm doing wrong, but for the life of me I don't know what. I should not that this error occurs when retrieving calendar items. |
To add further, I get this error when returning calendar entries, but I believe I will also get it when
Basically anything that needs to create a date on O365, in general reading a date is fine, it just fails for reading calendar entries. It is all calls that route to self._build_date_time_time_zone on ApiComponent, or direct to get_windows_tz. |
Example code that will cause failure:
|
I think in get_windows_tz in windows_tz.py changing:
Then in _build_date_time_time_zone in utils.py changing: However this does not solve the catch 22 in connection.py where anything that makes the if statement true will cause an error because dt.timezone requires a time delta.
|
…ANA ones) using the python 3.9 ZoneInfo objects
This should be fixed now. I will release a new version with the changes (2.0.33) soon. I plan to release a new O365 version changing how datetime timezones are worked with. Please see #1051 |
Thanks. I'll download based on latest commit and give it a go |
released 2.0.33 with the fix |
I'm trying to upgrade to the latest O365 release (2.0.31), with no changes to my code I get this error:
TypeError: timezone() argument 1 must be datetime.timedelta, not str
The call I'm making is this:
account = Account( credentials, token_backend=token_backend, timezone=("UTC"), main_resource=main_resource )
If I remove the timezone from the call:
account = Account( credentials, token_backend=token_backend, main_resource=main_resource )
I get this error:
Is this expected, or is there a timezone parameter I can pass in which will remove the warning? I've tried passing in timedelta(microseconds=0) as implied in the first error, but I get the same as the second error.
It's probably me just missing something, but I can't see what it is.
The text was updated successfully, but these errors were encountered: