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

Proposed fix for issue 75: handle offset-naive and offset-aware datetimes #76

Merged
merged 3 commits into from
Jun 21, 2017
Merged

Proposed fix for issue 75: handle offset-naive and offset-aware datetimes #76

merged 3 commits into from
Jun 21, 2017

Conversation

htgoebel
Copy link
Contributor

Proposed fix for issue #75, including test-cases.

This assumes that a DTSTART entry without time and time-zone information has to be handled "time-zone agnostic" and thus inhibits that until will have tzinfo set. If this has to behave differently, please let me know and I'll happily adjust the test-cases and the fix to whatever is required.

@mortlind
Copy link

mortlind commented Oct 3, 2017

I am on Debian and my radicale 2.1.5 installation using python3-vobject v. 0.9.5-1 still has these issues. Any good explanations?

@wpercy
Copy link
Contributor

wpercy commented Oct 3, 2017

@mortlind can you post the code you were trying to run and the full traceback?

@mortlind
Copy link

mortlind commented Oct 3, 2017

@wpercy The traceback:

2017-10-03 17:08:07,936 - [-4ae004c0] WARNING: Bad PUT request on '/ml/26d81a3a-f550-2e54-890d-d570f6090000/1507043287.R436.ics': Failed to store item '1507043287.R436.ics' in collection 'ml/26d81a3a-f550-2e54-890d-d570f6090000'
: can't compare offset-naive and offset-aware datetimes
Traceback (most recent call last):
  File "/usr/lib/python3/dist-packages/radicale/storage.py", line 1415, in upload
    href, vobject_item)
  File "/usr/lib/python3/dist-packages/radicale/storage.py", line 1244, in _store_item_cache
    content = self._item_cache_content(href, vobject_item, cache_hash)
  File "/usr/lib/python3/dist-packages/radicale/storage.py", line 1238, in _item_cache_content
    tag, start, end = xmlutils.find_tag_and_time_range(vobject_item)
  File "/usr/lib/python3/dist-packages/radicale/xmlutils.py", line 638, in find_tag_and_time_range
    _visit_time_ranges(vobject_item, tag, range_fn, infinity_fn)
  File "/usr/lib/python3/dist-packages/radicale/xmlutils.py", line 343, in _visit_time_ranges
    for dtstart in dtstarts:
  File "/usr/lib/python3/dist-packages/dateutil/rrule.py", line 1375, in _iter
    while exlist and exlist[0] < ritem:
  File "/usr/lib/python3/dist-packages/dateutil/rrule.py", line 1312, in __lt__
    return self.dt < other.dt
TypeError: can't compare offset-naive and offset-aware datetimes

The above exception was the direct cause of the following exception:

Traceback (most recent call last):
  File "/usr/lib/python3/dist-packages/radicale/__init__.py", line 900, in do_PUT
    new_item = parent_item.upload(href, items[0])
  File "/usr/lib/python3/dist-packages/radicale/storage.py", line 1418, in upload
    (href, self.path, e)) from e
ValueError: Failed to store item '1507043287.R436.ics' in collection 'ml/26d81a3a-f550-2e54-890d-d570f6090000': can't compare offset-naive and offset-aware datetimes

@wpercy
Copy link
Contributor

wpercy commented Oct 3, 2017

@mortlind This is actually an dateutil error:

File "/usr/lib/python3/dist-packages/dateutil/rrule.py", line 1312, in __lt__
    return self.dt < other.dt

@mortlind
Copy link

mortlind commented Oct 3, 2017

@wpercy OK. Is it dateutil I must update? I am on version
2.6.1-1 of python3-dateutil.

@htgoebel
Copy link
Contributor Author

htgoebel commented Oct 3, 2017

@mortlind This is a different error (maybe caused by radicale). Look at the traceback: File "/usr/lib/python3/dist-packages/radicale/xmlutils.py", line 343 is the last one before dateutil. This pull-request solved an error caused by "…/site-packages/vobject/icalendar.py", line 501.

@mortlind
Copy link

mortlind commented Oct 3, 2017

@htgoebel @wpercy Thanks for your kind and quick help in understanding. Sorry that i barged in like that, without properly trying to understand it myself beforehand. I am now in the painful process of re-creating all events and contacts while migrating from Radicale 1.x to 2.x :-/

@cpitclaudel
Copy link

@mortlind I think you were right to post here; AFAICT, the issue is caused by vobject :) The backtrace doesn't show it clearly, but the issue is raised when Radicale iterating on a stream of values created by vobject through the getrruleset method, and it's the iterator that vobject returned that raises the exception (see #139).

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

Successfully merging this pull request may close these issues.

5 participants