# Buggy code
def redraw(self):
    fc = len(self.master.view)
    if self.master.view.focus.flow is None:
        offset = 0
    else:
        offset = self.master.view.focus.index + 1

    if self.master.options.order_reversed:
        arrow = common.SYMBOL_UP
    else:
        arrow = common.SYMBOL_DOWN

    t = [
        ("heading", ("%s [%s/%s]" % (arrow, offset, fc)).ljust(11)),
    ]

    if self.master.server.bound:
        host = self.master.server.address.host
        if host == "0.0.0.0":
            host = "*"
        boundaddr = "[%s:%s]" % (host, self.master.server.address.port)
    else:
        boundaddr = ""
    t.extend(self.get_status())
    status = urwid.AttrWrap(
        urwid.Columns(
            [
                urwid.Text(t),
                urwid.Text([self.helptext, boundaddr], align="right"),
            ]
        ),
        "heading",
    )
    self.ib._w = status


# Traceback (ValueError)
Traceback (most recent call last):
File "/usr/local/Cellar/mitmproxy/0.18.2_1/libexec/lib/python2.7/site-packages/mitmproxy/console/master.py", line 482, in run
self.loop.run()
File "/usr/local/Cellar/mitmproxy/0.18.2_1/libexec/lib/python2.7/site-packages/urwid/main_loop.py", line 278, in run
self._run()
File "/usr/local/Cellar/mitmproxy/0.18.2_1/libexec/lib/python2.7/site-packages/urwid/main_loop.py", line 376, in _run
self.event_loop.run()
File "/usr/local/Cellar/mitmproxy/0.18.2_1/libexec/lib/python2.7/site-packages/urwid/main_loop.py", line 682, in run
self._loop()
File "/usr/local/Cellar/mitmproxy/0.18.2_1/libexec/lib/python2.7/site-packages/urwid/main_loop.py", line 719, in _loop
self._watch_files[fd]()
File "/usr/local/Cellar/mitmproxy/0.18.2_1/libexec/lib/python2.7/site-packages/urwid/raw_display.py", line 393, in <lambda>
event_loop, callback, self.get_available_raw_input())
File "/usr/local/Cellar/mitmproxy/0.18.2_1/libexec/lib/python2.7/site-packages/urwid/raw_display.py", line 493, in parse_input
callback(processed, processed_codes)
File "/usr/local/Cellar/mitmproxy/0.18.2_1/libexec/lib/python2.7/site-packages/urwid/main_loop.py", line 403, in _update
self.process_input(keys)
File "/usr/local/Cellar/mitmproxy/0.18.2_1/libexec/lib/python2.7/site-packages/urwid/main_loop.py", line 503, in process_input
k = self._topmost_widget.keypress(self.screen_size, k)
File "/usr/local/Cellar/mitmproxy/0.18.2_1/libexec/lib/python2.7/site-packages/mitmproxy/console/window.py", line 86, in keypress
k = super(self.__class__, self).keypress(size, k)
File "/usr/local/Cellar/mitmproxy/0.18.2_1/libexec/lib/python2.7/site-packages/urwid/container.py", line 1128, in keypress
return self.body.keypress( (maxcol, remaining), key )
File "/usr/local/Cellar/mitmproxy/0.18.2_1/libexec/lib/python2.7/site-packages/mitmproxy/console/flowlist.py", line 385, in keypress
return urwid.ListBox.keypress(self, size, key)
File "/usr/local/Cellar/mitmproxy/0.18.2_1/libexec/lib/python2.7/site-packages/urwid/listbox.py", line 987, in keypress
key = focus_widget.keypress((maxcol,),key)
File "/usr/local/Cellar/mitmproxy/0.18.2_1/libexec/lib/python2.7/site-packages/mitmproxy/console/flowlist.py", line 179, in keypress
self.state.disable_marked_filter()
File "/usr/local/Cellar/mitmproxy/0.18.2_1/libexec/lib/python2.7/site-packages/mitmproxy/console/master.py", line 183, in disable_marked_filter
self.set_focus_flow(nearest_marked)
File "/usr/local/Cellar/mitmproxy/0.18.2_1/libexec/lib/python2.7/site-packages/mitmproxy/console/master.py", line 107, in set_focus_flow
self.set_focus(self.view.index(f))
File "/usr/local/Cellar/mitmproxy/0.18.2_1/libexec/lib/python2.7/site-packages/mitmproxy/flow/state.py", line 36, in index
return self._list.index(f)
ValueError: None is not in list

mitmproxy has crashed!
Please lodge a bug report at:
https://github.com/mitmproxy/mitmproxy
Shutting down...

# Fixed code
def redraw(self):
    fc = len(self.master.view)
    if self.master.view.focus.flow is None:
        offset = 0
    else:
        offset = self.master.view.focus.index + 1

    if self.master.options.order_reversed:
        arrow = common.SYMBOL_UP
    else:
        arrow = common.SYMBOL_DOWN

    marked = ""
    if self.master.view.show_marked:
        marked = "M"

    t = [
        ("heading", ("%s %s [%s/%s]" % (arrow, marked, offset, fc)).ljust(11)),
    ]

    if self.master.server.bound:
        host = self.master.server.address.host
        if host == "0.0.0.0":
            host = "*"
        boundaddr = "[%s:%s]" % (host, self.master.server.address.port)
    else:
        boundaddr = ""
    t.extend(self.get_status())
    status = urwid.AttrWrap(
        urwid.Columns(
            [
                urwid.Text(t),
                urwid.Text([self.helptext, boundaddr], align="right"),
            ]
        ),
        "heading",
    )
    self.ib._w = status