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

'zoneinfo.ZoneInfo' object has no attribute 'zone' #1047

Closed MarcoMiano closed 5 months ago

MarcoMiano commented 5 months ago

Hi, i'm trying to write a simple script for reading calendars events. but I get the error in the title if I just install O365 with pip. The error occurs with the following packages installed:

beautifulsoup4 = 4.12.3
certifi = 2023.11.17
charset-normalizer 3.3.2
idna = 3.6
O365 = 2.0.32
oauthlib = 3.2.2
pip = 23.3.1
python = 3.12.1
python-dateutil = 2.8.2
pytz = 2023.3.post1
requests = 2.31.0
requests-oauthlib = 1.3.1
setuptools = 68.2.2
six = 1.16.0
soupsieve = 2.5
stringcase = 1.2.0
tzdata = 2023.4
tzlocal = 5.2
urllib3 = 2.1.0
wheel = 0.41.2

Full Error:

Traceback (most recent call last):
  File "c:\[redacted]\main.py", line 39, in <module>
    main()
  File "c:\[redacted]\main.py", line 34, in main
    for event in events:
  File "C:\[redacted]\AppData\Local\anaconda3\envs\work\Lib\site-packages\O365\calendar.py", line 1805, in <genexpr>
    events = (self.event_constructor(parent=self,
              ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "C:\[redacted]\AppData\Local\anaconda3\envs\work\Lib\site-packages\O365\calendar.py", line 911, in __init__
    self.__recurrence = EventRecurrence(event=self,
                        ^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "C:\[redacted]\AppData\Local\anaconda3\envs\work\Lib\site-packages\O365\calendar.py", line 137, in __init__
    get_windows_tz(self.protocol.timezone))
    ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "C:\[redacted]\AppData\Local\anaconda3\envs\work\Lib\site-packages\O365\utils\windows_tz.py", line 638, in get_windows_tz
    iana_tz.zone if isinstance(iana_tz, tzinfo) else iana_tz)

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

If I roll back to tzlocal 2.1 pip complains that tzlocal should be >= 5.0 but i don't get the error anymore.

ps: typechecking will broke with all the class constructors type with * | None... not really a problem BTW. pps: probably a problem of conda, but installing O365 with conda install is nearly impossible

MarcoMiano commented 5 months ago

didn't saw #1044... sry