# Buggy code
def delete_this(_):
    if self.event.ref == "PROTO":
        instance = self.event.start
    else:
        instance = self.event.ref
    self.event.delete_instance(instance)

    self.eventcolumn.pane.collection.update(self.event)
    self.eventcolumn.pane.window.backtrack()


# Traceback (ValueError)
debug: using the config file at /home/eisfreak7/.config/khal/khal.conf
debug: khal 0.6.1.dev205+ngc8a11b0.d20151117
debug: Using config:
debug: [calendars]
debug:   [[cal1]]
debug:     path: /home/timo/data/calendars/cal1.ics/
debug:     color: dark blue
debug:     readonly: False
debug:     type: calendar
debug:   [[cal2]]
debug:     path: /home/timo/data/calendars/cal2.ics/
debug:     color: light blue
debug:     readonly: False
debug:     type: calendar
debug:   [[cal3]]
debug:     path: /home/timo/data/calendars/cal3.ics/
debug:     color: dark magenta
debug:     readonly: False
debug:     type: calendar
debug:   [[cal4]]
debug:     path: /home/timo/data/calendars/cal4.ics/
debug:     color: dark cyan
debug:     readonly: False
debug:     type: calendar
debug: [locale]
debug:   longdateformat: %Y-%m-%d
debug:   longdatetimeformat: %Y-%m-%d %H:%M
debug:   datetimeformat: %y-%m-%d %H:%M
debug:   timeformat: %H:%M
debug:   dateformat: %y-%m-%d
debug:   encoding: utf-8
debug:   firstweekday: 0
debug:   unicode_symbols: True
debug:   default_timezone: Europe/Berlin
debug:   local_timezone: Europe/Berlin
debug:   weeknumbers: False
debug: [default]
debug:   default_command: agenda
debug:   print_new: event
debug:   days: 2
debug:   default_calendar: None
debug:   show_all_days: False
debug:   highlight_event_days: False
debug: [sqlite]
debug:   path: /home/eisfreak7/.local/share/khal/khal.db
debug: [keybindings]
debug:   up: ['up', 'k']
debug:   down: ['down', 'j']
debug:   right: ['right', 'l', ' ']
debug:   left: ['left', 'h', 'backspace']
debug:   new: ['n']
debug:   delete: ['d']
debug:   view: ['enter', 'tab']
debug:   today: ['t']
debug:   save: ['meta enter']
debug:   duplicate: ['p']
debug: [view]
debug:   event_view_weighting: 1
debug:   event_view_always_visible: False
debug:   theme: dark
debug:   frame: False
debug: [highlight_days]
debug:   method: fg
debug:   color:
debug:   multiple:
debug:   default_color:
debug: created version table
debug: tables for calendar cal1 exist
debug: created version table
debug: tables for calendar cal2 exist
debug: created version table
debug: tables for calendar cal3 exist
debug: created version table
debug: tables for calendar cal4 exist
Traceback (most recent call last):
File "/usr/lib/python3.5/site-packages/khal/ui/__init__.py", line 675, in start_pane
loop.run()
File "/usr/lib/python3.5/site-packages/urwid/main_loop.py", line 278, in run
self._run()
File "/usr/lib/python3.5/site-packages/urwid/main_loop.py", line 375, in _run
self.event_loop.run()
File "/usr/lib/python3.5/site-packages/urwid/main_loop.py", line 678, in run
self._loop()
File "/usr/lib/python3.5/site-packages/urwid/main_loop.py", line 715, in _loop
self._watch_files[fd]()
File "/usr/lib/python3.5/site-packages/urwid/raw_display.py", line 392, in <lambda>
event_loop, callback, self.get_available_raw_input())
File "/usr/lib/python3.5/site-packages/urwid/raw_display.py", line 492, in parse_input
callback(processed, processed_codes)
File "/usr/lib/python3.5/site-packages/urwid/main_loop.py", line 399, in _update
self.process_input(keys)
File "/usr/lib/python3.5/site-packages/urwid/main_loop.py", line 499, in process_input
k = self._topmost_widget.keypress(self.screen_size, k)
File "/usr/lib/python3.5/site-packages/urwid/wimp.py", line 643, in keypress
return self._current_widget.keypress(size, key)
File "/usr/lib/python3.5/site-packages/urwid/container.py", line 1128, in keypress
return self.body.keypress( (maxcol, remaining), key )
File "/usr/lib/python3.5/site-packages/urwid/container.py", line 592, in keypress
*self.calculate_padding_filler(size, True)), key)
File "/usr/lib/python3.5/site-packages/urwid/container.py", line 1587, in keypress
key = self.focus.keypress(tsize, key)
File "/usr/lib/python3.5/site-packages/urwid/container.py", line 2269, in keypress
key = w.keypress((mc,) + size[1:], key)
File "/usr/lib/python3.5/site-packages/urwid/container.py", line 1587, in keypress
key = self.focus.keypress(tsize, key)
File "/usr/lib/python3.5/site-packages/urwid/container.py", line 2269, in keypress
key = w.keypress((mc,) + size[1:], key)
File "/usr/lib/python3.5/site-packages/urwid/wimp.py", line 535, in keypress
self._emit('click')
File "/usr/lib/python3.5/site-packages/urwid/widget.py", line 463, in _emit
signals.emit_signal(self, name, self, *args)
File "/usr/lib/python3.5/site-packages/urwid/signals.py", line 264, in emit
result |= self._call_callback(callback, user_arg, user_args, args)
File "/usr/lib/python3.5/site-packages/urwid/signals.py", line 294, in _call_callback
return bool(callback(*args_to_pass))
File "/usr/lib/python3.5/site-packages/khal/ui/__init__.py", line 91, in delete_this
self.event.delete_instance(instance)
File "/usr/lib/python3.5/site-packages/khal/khalendar/event.py", line 422, in delete_instance
delete_instance(self._vevents['PROTO'], instance)
File "/usr/lib/python3.5/site-packages/khal/khalendar/aux.py", line 279, in delete_instance
_add_exdate(vevent, instance)
File "/usr/lib/python3.5/site-packages/khal/khalendar/aux.py", line 237, in _add_exdate
vevent.add('EXDATE', instance)
File "/usr/lib/python3.5/site-packages/icalendar/cal.py", line 174, in add
value = self._encode(name, value, parameters, encode)
File "/usr/lib/python3.5/site-packages/icalendar/cal.py", line 126, in _encode
obj = klass(value)
File "/usr/lib/python3.5/site-packages/icalendar/prop.py", line 247, in __init__
dt = vDDDTypes(dt)
File "/usr/lib/python3.5/site-packages/icalendar/prop.py", line 277, in __init__
raise ValueError('You must use datetime, date, timedelta or time')
ValueError: You must use datetime, date, timedelta or time

# Fixed code
def delete_this(_):
    self.event.delete_instance(self.event.recurrence_id)
    self.eventcolumn.pane.collection.update(self.event)
    self.eventcolumn.pane.window.backtrack()