From 30e926abf68257cfb53c4bba8637756ebbceba75 Mon Sep 17 00:00:00 2001 From: Florian Bruhin Date: Tue, 9 Sep 2014 22:29:17 +0200 Subject: [PATCH] Check duplicate keychains --- qutebrowser/config/keyconfparser.py | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/qutebrowser/config/keyconfparser.py b/qutebrowser/config/keyconfparser.py index 6e7bd55d4..8640ecb93 100644 --- a/qutebrowser/config/keyconfparser.py +++ b/qutebrowser/config/keyconfparser.py @@ -35,8 +35,8 @@ class KeyConfigError(Exception): lineno: The config line in which the exception occured. """ - def __init__(self): - super().__init__() + def __init__(self, msg=None): + super().__init__(msg) self.lineno = None @@ -163,6 +163,8 @@ class KeyConfigParser: """Add a new binding from keychain to command in section sectname.""" if sectname not in self.keybindings: self.keybindings[sectname] = collections.OrderedDict() + if keychain in self.get_bindings_for(sectname): + raise KeyConfigError("Duplicate keychain '{}'!".format(keychain)) self.keybindings[sectname][keychain] = command def get_bindings_for(self, section):