Repository: qutebrowser/qutebrowser

Issue:
Crash when unbinding <Esc> in passthrough mode
When adding this to `keys.conf`:

``` ini
[passthrough]
<unbound>
    <Escape>
```

We get:

```
Traceback (most recent call last):
  File "/home/florian/proj/qutebrowser/git/qutebrowser/config/parsers/keyconf.py", line 206, in unbind
    del sect[key]
KeyError: '<Escape>'

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "/usr/lib64/python3.5/runpy.py", line 170, in _run_module_as_main
    "__main__", mod_spec)
  File "/usr/lib64/python3.5/runpy.py", line 85, in _run_code
    exec(code, run_globals)
  File "/home/florian/proj/qutebrowser/git/qutebrowser/__main__.py", line 29, in <module>
    sys.exit(qutebrowser.qutebrowser.main())
  File "/home/florian/proj/qutebrowser/git/qutebrowser/qutebrowser.py", line 155, in main
    return app.run(args)
  File "/home/florian/proj/qutebrowser/git/qutebrowser/app.py", line 110, in run
    init(args, crash_handler)
  File "/home/florian/proj/qutebrowser/git/qutebrowser/app.py", line 137, in init
    _init_modules(args, crash_handler)
  File "/home/florian/proj/qutebrowser/git/qutebrowser/app.py", line 402, in _init_modules
    config.init(qApp)
  File "/home/florian/proj/qutebrowser/git/qutebrowser/config/config.py", line 254, in init
    _init_key_config(parent)
  File "/home/florian/proj/qutebrowser/git/qutebrowser/config/config.py", line 187, in _init_key_config
    parent=parent)
  File "/home/florian/proj/qutebrowser/git/qutebrowser/config/parsers/keyconf.py", line 99, in __init__
    self._read(relaxed)
  File "/home/florian/proj/qutebrowser/git/qutebrowser/config/parsers/keyconf.py", line 298, in _read
    self._read_keybinding(line)
  File "/home/florian/proj/qutebrowser/git/qutebrowser/config/parsers/keyconf.py", line 361, in _read_keybinding
    self._add_binding(self._cur_section, line, self._cur_command)
  File "/home/florian/proj/qutebrowser/git/qutebrowser/config/parsers/keyconf.py", line 371, in _add_binding
    self.unbind(keychain, mode=sectname)
  File "/home/florian/proj/qutebrowser/git/qutebrowser/config/parsers/keyconf.py", line 209, in unbind
    "'{}'!".format(key, mode))
qutebrowser.commands.cmdexc.CommandError: Can't find binding '<Escape>' in section 'passthrough'!
```



Discussion:
Can no longer reproduce this in 9cd2c9a
I can reproduce this with `<Escape>` (not `<Esc>` like mentioned above earlier).

Resolving patch:
diff --git a/qutebrowser/config/config.py b/qutebrowser/config/config.py
--- a/qutebrowser/config/config.py
+++ b/qutebrowser/config/config.py
@@ -186,7 +186,8 @@ def _init_key_config(parent):
         key_config = keyconf.KeyConfigParser(standarddir.config(), 'keys.conf',
                                              args.relaxed_config,
                                              parent=parent)
-    except (keyconf.KeyConfigError, UnicodeDecodeError) as e:
+    except (keyconf.KeyConfigError, cmdexc.CommandError,
+            UnicodeDecodeError) as e:
         log.init.exception(e)
         errstr = "Error while reading key config:\n"
         if e.lineno is not None:
diff --git a/qutebrowser/config/parsers/keyconf.py b/qutebrowser/config/parsers/keyconf.py
--- a/qutebrowser/config/parsers/keyconf.py
+++ b/qutebrowser/config/parsers/keyconf.py
@@ -322,7 +322,7 @@ def _read(self, relaxed=False):
                         else:
                             line = line.strip()
                             self._read_command(line)
-                    except KeyConfigError as e:
+                    except (KeyConfigError, cmdexc.CommandError) as e:
                         if relaxed:
                             continue
                         else:


Test patch: