From 19619bff988bd327b8e4a0996bb7d1b3f1b53334 Mon Sep 17 00:00:00 2001 From: Chris Jones Date: Mon, 13 Oct 2008 09:37:26 +0100 Subject: [PATCH] rework keyboard event lookup failure handling with suggestions from Thomas. Relates to LP #280959 --- terminatorlib/keybindings.py | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/terminatorlib/keybindings.py b/terminatorlib/keybindings.py index dfdeb36b..af915a26 100644 --- a/terminatorlib/keybindings.py +++ b/terminatorlib/keybindings.py @@ -81,9 +81,11 @@ class TerminatorKeybindings: raise KeymapError("Unhandled modifier '<%s>'" % modifier) def lookup(self, event): - if not event: - raise KeymapError("lookup called with no event") - keyval, egroup, level, consumed = self.keymap.translate_keyboard_state(event.hardware_keycode, event.state, event.group) + try: + keyval, egroup, level, consumed = self.keymap.translate_keyboard_state(event.hardware_keycode, event.state, event.group) + except TypeError: + err ("keybindings.lookup failed to translate keyboard event: %s"%dir(event)) + return None mask = (event.state & ~consumed) & self._masks return self._lookup.get(mask, self.empty).get(event.keyval, None)