# Buggy code
def __init__(self, rrule, conf, startdt):
    self._conf = conf
    self._startdt = startdt
    self._rrule = rrule
    self.repeat = bool(rrule)
    self._allow_edit = not self.repeat or self.check_understood_rrule(rrule)
    self.repeat_box = urwid.CheckBox(
        "Repeat: ",
        state=self.repeat,
        on_state_change=self.check_repeat,
    )

    if "UNTIL" in self._rrule:
        self._until = "Until"
    elif "COUNT" in self._rrule:
        self._until = "Repetitions"
    else:
        self._until = "Forever"

    recurrence = self._rrule["freq"][0].lower() if self._rrule else "weekly"
    self.recurrence_choice = Choice(
        ["daily", "weekly", "monthly", "yearly"],
        recurrence,
        callback=self.rebuild,
    )
    self.interval_edit = PositiveIntEdit(
        caption="every:",
        edit_text=str(self._rrule.get("INTERVAL", [1])[0]),
    )
    self.until_choice = Choice(
        ["Forever", "Until", "Repetitions"],
        self._until,
        callback=self.rebuild,
    )

    count = str(self._rrule.get("COUNT", [1])[0])
    self.repetitions_edit = PositiveIntEdit(edit_text=count)

    until = self._rrule.get("UNTIL", [None])[0]
    if until is None and isinstance(self._startdt, datetime):
        until = self._startdt.date()
    elif until is None:
        until = self._startdt

    if isinstance(until, datetime):
        until = datetime.date()
    self.until_edit = DateEdit(
        until,
        self._conf["locale"]["longdateformat"],
        lambda _: None,
        self._conf["locale"]["weeknumbers"],
        self._conf["locale"]["firstweekday"],
    )

    self._rebuild_weekday_checks()
    self._rebuild_monthly_choice()
    self._pile = pile = NPile([urwid.Text("")])
    urwid.WidgetWrap.__init__(self, pile)
    self.rebuild()


# Traceback (TypeError)
Traceback (most recent call last):i Walker (*1979) ⟳
File "/home/andreas/src/env-3.6/lib/python3.6/site-packages/khal/ui/__init__.py", line 1300, in start_pane
loop.run()
File "/home/andreas/src/env-3.6/lib/python3.6/site-packages/urwid/main_loop.py", line 278, in run
self._run()
File "/home/andreas/src/env-3.6/lib/python3.6/site-packages/urwid/main_loop.py", line 376, in _run
self.event_loop.run()
File "/home/andreas/src/env-3.6/lib/python3.6/site-packages/urwid/main_loop.py", line 682, in run
self._loop()
File "/home/andreas/src/env-3.6/lib/python3.6/site-packages/urwid/main_loop.py", line 719, in _loop
self._watch_files[fd]()
File "/home/andreas/src/env-3.6/lib/python3.6/site-packages/urwid/raw_display.py", line 393, in <lambda>
event_loop, callback, self.get_available_raw_input())
File "/home/andreas/src/env-3.6/lib/python3.6/site-packages/urwid/raw_display.py", line 493, in parse_input
callback(processed, processed_codes)
File "/home/andreas/src/env-3.6/lib/python3.6/site-packages/urwid/main_loop.py", line 403, in _update
self.process_input(keys)
File "/home/andreas/src/env-3.6/lib/python3.6/site-packages/urwid/main_loop.py", line 503, in process_input
k = self._topmost_widget.keypress(self.screen_size, k)
File "/home/andreas/src/env-3.6/lib/python3.6/site-packages/urwid/wimp.py", line 643, in keypress
return self._current_widget.keypress(size, key)
File "/home/andreas/src/env-3.6/lib/python3.6/site-packages/urwid/container.py", line 1128, in keypress
return self.body.keypress( (maxcol, remaining), key
File "/home/andreas/src/env-3.6/lib/python3.6/site-packages/khal/ui/__init__.py", line 1106, in keypress
return super().keypress(size, key)
File "/home/andreas/src/env-3.6/lib/python3.6/site-packages/khal/ui/base.py", line 82, in keypress
return super().keypress(size, key)
File "/home/andreas/src/env-3.6/lib/python3.6/site-packages/khal/ui/widgets.py", line 308, in keypress
key = super(NextMixin, self).keypress(size, key)
File "/home/andreas/src/env-3.6/lib/python3.6/site-packages/urwid/container.py", line 2269, in keypress
key = w.keypress((mc,) + size[1:], key)
File "/home/andreas/src/env-3.6/lib/python3.6/site-packages/khal/ui/__init__.py", line 919, in keypress
self.edit(self.focus_event.event)
File "/home/andreas/src/env-3.6/lib/python3.6/site-packages/khal/ui/__init__.py", line 756, in edit
editor = EventEditor(self.pane, event, update_colors, always_save=always_save)
File "/home/andreas/src/env-3.6/lib/python3.6/site-packages/khal/ui/editor.py", line 342, in __init__
self.event.recurobject, self._conf, event.start_local,
File "/home/andreas/src/env-3.6/lib/python3.6/site-packages/khal/ui/editor.py", line 569, in __init__
until = datetime.date()
TypeError: descriptor 'date' of 'datetime.datetime' object needs an argument

# Fixed code
def __init__(self, rrule, conf, startdt):
    self._conf = conf
    self._startdt = startdt
    self._rrule = rrule
    self.repeat = bool(rrule)
    self._allow_edit = not self.repeat or self.check_understood_rrule(rrule)
    self.repeat_box = urwid.CheckBox(
        "Repeat: ",
        state=self.repeat,
        on_state_change=self.check_repeat,
    )

    if "UNTIL" in self._rrule:
        self._until = "Until"
    elif "COUNT" in self._rrule:
        self._until = "Repetitions"
    else:
        self._until = "Forever"

    recurrence = self._rrule["freq"][0].lower() if self._rrule else "weekly"
    self.recurrence_choice = Choice(
        ["daily", "weekly", "monthly", "yearly"],
        recurrence,
        callback=self.rebuild,
    )
    self.interval_edit = PositiveIntEdit(
        caption="every:",
        edit_text=str(self._rrule.get("INTERVAL", [1])[0]),
    )
    self.until_choice = Choice(
        ["Forever", "Until", "Repetitions"],
        self._until,
        callback=self.rebuild,
    )

    count = str(self._rrule.get("COUNT", [1])[0])
    self.repetitions_edit = PositiveIntEdit(edit_text=count)

    until = self._rrule.get("UNTIL", [None])[0]
    if until is None and isinstance(self._startdt, datetime):
        until = self._startdt.date()
    elif until is None:
        until = self._startdt

    if isinstance(until, datetime):
        until = until.date()
    self.until_edit = DateEdit(
        until,
        self._conf["locale"]["longdateformat"],
        lambda _: None,
        self._conf["locale"]["weeknumbers"],
        self._conf["locale"]["firstweekday"],
    )

    self._rebuild_weekday_checks()
    self._rebuild_monthly_choice()
    self._pile = pile = NPile([urwid.Text("")])
    urwid.WidgetWrap.__init__(self, pile)
    self.rebuild()