collective / icalendar

icalendar parser library for Python
https://icalendar.readthedocs.io/en/latest/
Other
982 stars 169 forks source link

Decoding categories throws AssertionError #279

Open chris246 opened 5 years ago

chris246 commented 5 years ago

When decoding categories from an ical feed, an AssertionError is thrown: component.decoded('categories', []) Stacktrace:

File "\lib\site-packages\icalendar\cal.py", line 237, in decoded
    return self._decode(name, value)
  File "\lib\site-packages\icalendar\cal.py", line 220, in _decode
    decoded = types_factory.from_ical(name, value)
  File "\lib\site-packages\icalendar\prop.py", line 1042, in from_ical
    decoded = type_class.from_ical(value)
  File "\lib\site-packages\icalendar\prop.py", line 282, in from_ical
    out = unescape_char(ical).split(",")
  File "\lib\site-packages\icalendar\parser.py", line 34, in unescape_char
    assert isinstance(text, (compat.unicode_type, compat.bytes_type))
AssertionError

The type of ical in file prop.py vCategory.from_ical (line 281) is icalendar.prop.vCategory

Using component.get('categories', []) works

icalender version: 4.0.3

swolebro commented 5 years ago

Without seeing your .ics file, I can't say for certain how you're reaching that assertion, but I'm 95% confident it's related to the changes in 20e09f352, which created a designated class for VCATEGORY fields, whereas before they were simple strings. Reverting to icalendar==4.0.2 would likely fix the issue until it gets resolved here.

This bug in a client application seems to stem from the same: pimutils/khal#823

NB: Not a developer of this library, just a new user of Khal debugging my own issues with it.