# Buggy code
def check_understood_rrule(rrule):
    """test if we can reproduce `rrule`."""
    keys = set(rrule.keys())
    freq = rrule.get("FREQ", [None])[0]
    unsupported_rrule_parts = {
        "BYSECOND",
        "BYMINUTE",
        "BYHOUR",
        "BYYEARDAY",
        "BYWEEKNO",
        "BYMONTH",
        "BYSETPOS",
    }
    if keys.intersection(unsupported_rrule_parts):
        return False
    # we don't support negative BYMONTHDAY numbers
    if rrule.get("BYMONTHDAY", ["1"])[0][0] == "-":
        return False
    if rrule.get("BYDAY", ["1"])[0][0] == "-":
        return False
    if freq not in ["DAILY", "WEEKLY", "MONTHLY", "YEARLY"]:
        return False
    if "BYDAY" in keys and freq == "YEARLY":
        return False
    return True


# Traceback (TypeError)
$ ikhal
Traceback (most recent call last):
File "/usr/lib/python3/dist-packages/khal/ui/__init__.py", line 1296, in start_pane
loop.run()
File "/usr/lib/python3/dist-packages/urwid/main_loop.py", line 278, in run
self._run()
File "/usr/lib/python3/dist-packages/urwid/main_loop.py", line 376, in _run
self.event_loop.run()
File "/usr/lib/python3/dist-packages/urwid/main_loop.py", line 682, in run
self._loop()
File "/usr/lib/python3/dist-packages/urwid/main_loop.py", line 719, in _loop
self._watch_files[fd]()
File "/usr/lib/python3/dist-packages/urwid/raw_display.py", line 393, in <lambda>
event_loop, callback, self.get_available_raw_input())
File "/usr/lib/python3/dist-packages/urwid/raw_display.py", line 493, in parse_input
callback(processed, processed_codes)
File "/usr/lib/python3/dist-packages/urwid/main_loop.py", line 403, in _update
self.process_input(keys)
File "/usr/lib/python3/dist-packages/urwid/main_loop.py", line 503, in process_input
k = self._topmost_widget.keypress(self.screen_size, k)
File "/usr/lib/python3/dist-packages/urwid/wimp.py", line 643, in keypress
return self._current_widget.keypress(size, key)
File "/usr/lib/python3/dist-packages/urwid/container.py", line 1128, in keypress
return self.body.keypress( (maxcol, remaining), key )
File "/usr/lib/python3/dist-packages/khal/ui/__init__.py", line 1102, in keypress
return super().keypress(size, key)
File "/usr/lib/python3/dist-packages/khal/ui/base.py", line 82, in keypress
return super().keypress(size, key)
File "/usr/lib/python3/dist-packages/khal/ui/widgets.py", line 308, in keypress
key = super(NextMixin, self).keypress(size, key)
File "/usr/lib/python3/dist-packages/urwid/container.py", line 2269, in keypress
key = w.keypress((mc,) + size[1:], key)
File "/usr/lib/python3/dist-packages/khal/ui/__init__.py", line 915, in keypress
self.edit(self.focus_event.event)
File "/usr/lib/python3/dist-packages/khal/ui/__init__.py", line 752, in edit
editor = EventEditor(self.pane, event, update_colors, always_save=always_save)
File "/usr/lib/python3/dist-packages/khal/ui/editor.py", line 342, in __init__
self.event.recurobject, self._conf, event.start_local,
File "/usr/lib/python3/dist-packages/khal/ui/editor.py", line 533, in __init__
self._allow_edit = not self.repeat or self.check_understood_rrule(rrule)
File "/usr/lib/python3/dist-packages/khal/ui/editor.py", line 620, in check_understood_rrule
if rrule.get('BYMONTHDAY', ['1'])[0][0] == '-':
TypeError: 'vInt' object does not support indexing

# Fixed code
def check_understood_rrule(rrule):
    """test if we can reproduce `rrule`."""
    keys = set(rrule.keys())
    freq = rrule.get("FREQ", [None])[0]
    unsupported_rrule_parts = {
        "BYSECOND",
        "BYMINUTE",
        "BYHOUR",
        "BYYEARDAY",
        "BYWEEKNO",
        "BYMONTH",
        "BYSETPOS",
    }
    if keys.intersection(unsupported_rrule_parts):
        return False
    if len(rrule.get("BYMONTHDAY", [1])) > 1:
        return False
    # we don't support negative BYMONTHDAY numbers
    # don't need to check whole list, we only support one monthday anyway
    if rrule.get("BYMONTHDAY", [1])[0] < 1:
        return False
    if rrule.get("BYDAY", ["1"])[0][0] == "-":
        return False
    if freq not in ["DAILY", "WEEKLY", "MONTHLY", "YEARLY"]:
        return False
    if "BYDAY" in keys and freq == "YEARLY":
        return False
    return True