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:
parent
39e8cfef6c
commit
61727e35c4
|
@ -28,13 +28,6 @@ from util import err
|
||||||
|
|
||||||
class KeymapError(Exception):
|
class KeymapError(Exception):
|
||||||
"""Custom exception for errors in keybinding configurations"""
|
"""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('<([^<]+)>')
|
MODIFIER = re.compile('<([^<]+)>')
|
||||||
class Keybindings:
|
class Keybindings:
|
||||||
|
@ -71,15 +64,15 @@ class Keybindings:
|
||||||
bindings = (bindings,)
|
bindings = (bindings,)
|
||||||
|
|
||||||
for binding in bindings:
|
for binding in bindings:
|
||||||
if binding is None or binding == "None":
|
if not binding or binding == "None":
|
||||||
continue
|
continue
|
||||||
|
|
||||||
try:
|
try:
|
||||||
keyval, mask = self._parsebinding(binding)
|
keyval, mask = self._parsebinding(binding)
|
||||||
# Does much the same, but with poorer error handling.
|
# Does much the same, but with poorer error handling.
|
||||||
#keyval, mask = gtk.accelerator_parse(binding)
|
#keyval, mask = gtk.accelerator_parse(binding)
|
||||||
except KeymapError:
|
except KeymapError as e:
|
||||||
continue
|
err ("keybindings.reload failed to parse binding '%s': %s" % (binding, e))
|
||||||
else:
|
else:
|
||||||
if mask & gtk.gdk.SHIFT_MASK:
|
if mask & gtk.gdk.SHIFT_MASK:
|
||||||
if keyval == gtk.keysyms.Tab:
|
if keyval == gtk.keysyms.Tab:
|
||||||
|
|
Loading…
Reference in New Issue