skarim / vobject

A full-featured Python package for parsing and creating iCalendar and vCard files
https://vobject.sameenkarim.com
258 stars 93 forks source link

TypeError: can't compare offset-naive and offset-aware datetimes in getrruleset #139

Open cpitclaudel opened 5 years ago

cpitclaudel commented 5 years ago

Hi there,

The following example is responsible for the bug at https://github.com/Kozea/Radicale/issues/925 ; an event that has an UTC timestamp in EXDATE but plain dates as DTSTART and DTEND will cause an exception in getrruleset:

#!/usr/bin/env python3
import vobject

REPRO = """
BEGIN:VCALENDAR
PRODID:-//Google Inc//Google Calendar 70.9054//EN
VERSION:2.0
CALSCALE:GREGORIAN
METHOD:PUBLISH

BEGIN:VEVENT
DTSTART;VALUE=DATE:19910520
DTEND;VALUE=DATE:19910521
CREATED:20101031T171909Z
DESCRIPTION:
EXDATE;VALUE=DATE-TIME:20150520T000000Z
RRULE:FREQ=YEARLY;WKST=MO;UNTIL=20170519T235959Z;BYMONTH=5;BYMONTHDAY=20
SUMMARY:Test
END:VEVENT

END:VCALENDAR
"""

vobj = vobject.readOne(REPRO).vevent
for dt in vobj.getrruleset(addRDate=True):
    print(dt)
Traceback (most recent call last):
  File "./repro.py", line 25, in <module>
    for dt in vobj.getrruleset(addRDate=True):
  File "/home/clement/.local/lib/python3.6/site-packages/dateutil/rrule.py", line 1400, in _iter
    while exlist and exlist[0] < ritem:
  File "/home/clement/.local/lib/python3.6/site-packages/dateutil/rrule.py", line 1337, in __lt__
    return self.dt < other.dt
TypeError: can't compare offset-naive and offset-aware datetimes

This seems to be related to https://github.com/eventable/vobject/issues/75 (cc @htgoebel).

h3xx commented 6 months ago

Since this project is so stale (6 years at this point), I doubt you'll hear back about this issue.

I wonder if this is an issue in the current fork, py-vobject/vobject. (I say current because that's the source for what's currently published on PyPI.)

I have vobject 0.9.7 installed from PyPI and can confirm that the error you're seeing is still happening. Perhaps some commit has happened to master since that release to fix it.

da4089 commented 5 months ago

I'm working with @skarim to reunite this repo with the fork. I'm hoping to make a new release that should address this problem soon.