khal
khal copied to clipboard
Lots of warnings on ikhal startup
Upon starting ikhal
, the terminal is filled with warnings in the form of:
Unknown exception happened.
Traceback (most recent call last):
File "/usr/lib/python3.8/site-packages/khal/khalendar/khalendar.py", line 330, in _update_vevent
update(event.raw, href=href, etag=etag, calendar=calendar)
File "/usr/lib/python3.8/site-packages/khal/khalendar/backend.py", line 214, in update
ical = utils.cal_from_ics(vevent_str)
File "/usr/lib/python3.8/site-packages/khal/utils.py", line 665, in cal_from_ics
return cal
UnboundLocalError: local variable 'cal' referenced before assignment
warning: Skipping <calendar-name-redacted>/<uui-redacted>1.ics: local variable 'cal' referenced before assignment
warning: This event will not be available in khal.
printing them all takes some time, so startup of the interface is largely delayed.
I'm on khal 0.10.1
Hi, i've got some warning too on my system but not from recent events, mostly on very old ones. My first investigations show me that it is about malformed ICS files events (TZ problem for example). This issue is related to the icalendar project. I'll try to do more research after #903.
I've been having the same issue for quite a while, seemingly affecting all events except for some subscribed web calendars. My personal calendar events are pretty much all created by either iOS or macOS calendars, published to a Radicale server.
Problem concern Radicale and Nextcloud server on my side.
This might help with debugging.
Hello, I run $ khal import main.ics
and get UnboundLocalError: local variable 'cal' referenced before assignment
.
I am running khal, version 0.10.1
installed with pip3
on Linux Mint 19.2
i downloaded my current calendar from my email provider as a .ics
file and wanted to use this as a starting point. It didn't import. I exported the same calendar as a .ics
file from within Thunderbird and had the same error message.
An .ics
exported from a random, almost empty calendar in Thunderbird was imported into khal without error.
I haven't used khal
before.
What can I do to make the import?
$ khal import main.ics 20:29:56
Traceback (most recent call last):
File "/usr/local/bin/khal", line 11, in <module>
sys.exit(main_khal())
File "/usr/lib/python3/dist-packages/click/core.py", line 722, in __call__
return self.main(*args, **kwargs)
File "/usr/lib/python3/dist-packages/click/core.py", line 697, in main
rv = self.invoke(ctx)
File "/usr/lib/python3/dist-packages/click/core.py", line 1066, in invoke
return _process_result(sub_ctx.command.invoke(sub_ctx))
File "/usr/lib/python3/dist-packages/click/core.py", line 895, in invoke
return ctx.invoke(self.callback, **ctx.params)
File "/usr/lib/python3/dist-packages/click/core.py", line 535, in invoke
return callback(*args, **kwargs)
File "/usr/lib/python3/dist-packages/click/decorators.py", line 17, in new_func
return f(get_current_context(), *args, **kwargs)
File "/usr/local/lib/python3.6/dist-packages/khal/cli.py", line 454, in import_ics
env={"calendars": ctx.obj['conf']['calendars']},
File "/usr/local/lib/python3.6/dist-packages/khal/controllers.py", line 557, in import_ics
vevents = utils.split_ics(ics, random_uid, conf['locale']['default_timezone'])
File "/usr/local/lib/python3.6/dist-packages/khal/utils.py", line 125, in split_ics
cal = cal_from_ics(ics)
File "/usr/local/lib/python3.6/dist-packages/khal/utils.py", line 665, in cal_from_ics
return cal
UnboundLocalError: local variable 'cal' referenced before assignment
Hi all,
iCalendar PR https://github.com/collective/icalendar/pull/304 merged into master seems to avoid the problem here, could you test test it in a venv
for example and make a return here?
If someone still has this issue, please also post a (anonymized) version of an offending event if you can identify one.
tests/cli_test.py::test_no_vevent actually reproduces a version of the "UnboundLocalError: local variable 'cal' referenced before assignment" but the test condition is faulty "assert 'No events' in result.output". Changing that test for another issue and marking and making it xfail with a reference to this issue.
Not sure how to fix this, but the problem is in cal_from_ics() where cal is unset if the first call to icalendar.Calendar.from_ical(ics) throws an exception and the condition in the except block returns false:
(len(error.args) > 0 and isinstance(error.args[0], str) and error.args[0].startswith('Offset must be less than 24 hours'))
for the test it fails because:
error.arg[0] == "Found no components where exactly one is required: ''"