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.

This commit is contained in:
Thomas Hurst 2012-05-17 00:02:16 +01:00
parent 39e8cfef6c
commit 61727e35c4
1 changed files with 3 additions and 10 deletions

View File

@ -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: