From 61727e35c4f60592c4269f2e3b8de68650ac0bb6 Mon Sep 17 00:00:00 2001 From: Thomas Hurst Date: Thu, 17 May 2012 00:02:16 +0100 Subject: [PATCH] Don't silently consume keybinding errors. Drop superfluous code from exception and fix the guard clause that was allowing empty bindings to reach the parse stage. --- terminatorlib/keybindings.py | 13 +++---------- 1 file changed, 3 insertions(+), 10 deletions(-) diff --git a/terminatorlib/keybindings.py b/terminatorlib/keybindings.py index 37eab7c5..0bda431b 100644 --- a/terminatorlib/keybindings.py +++ b/terminatorlib/keybindings.py @@ -28,13 +28,6 @@ from util import err class KeymapError(Exception): """Custom exception for errors in keybinding configurations""" - def __init__(self, value): - Exception.__init__(self, value) - self.value = value - self.action = 'unknown' - - def __str__(self): - return "Keybinding '%s' invalid: %s" % (self.action, self.value) MODIFIER = re.compile('<([^<]+)>') class Keybindings: @@ -71,15 +64,15 @@ class Keybindings: bindings = (bindings,) for binding in bindings: - if binding is None or binding == "None": + if not binding or binding == "None": continue try: keyval, mask = self._parsebinding(binding) # Does much the same, but with poorer error handling. #keyval, mask = gtk.accelerator_parse(binding) - except KeymapError: - continue + except KeymapError as e: + err ("keybindings.reload failed to parse binding '%s': %s" % (binding, e)) else: if mask & gtk.gdk.SHIFT_MASK: if keyval == gtk.keysyms.Tab: