Fix exception when getting function name for debug_keyboard action dispatch

Fixes #1401
This commit is contained in:
Kovid Goyal 2019-02-23 08:00:21 +05:30
parent aed504efdc
commit e44b331cc3
No known key found for this signature in database
GPG key ID: 06BC317B515ACE7C
2 changed files with 12 additions and 4 deletions

View file

@ -34,8 +34,8 @@
from .session import create_session
from .tabs import SpecialWindow, SpecialWindowInstance, TabManager
from .utils import (
get_editor, get_primary_selection, is_path_in_temp_dir, log_error,
open_url, parse_address_spec, remove_socket_file, safe_print,
func_name, get_editor, get_primary_selection, is_path_in_temp_dir,
log_error, open_url, parse_address_spec, remove_socket_file, safe_print,
set_primary_selection, single_instance, startup_notification_handler
)
@ -577,7 +577,7 @@ def dispatch_action(self, key_action):
f = getattr(self, key_action.func, None)
if f is not None:
if self.args.debug_keyboard:
print('Keypress matched action:', f.__name__)
print('Keypress matched action:', func_name(f))
passthrough = f(*key_action.args)
if passthrough is not True:
return True
@ -592,7 +592,7 @@ def dispatch_action(self, key_action):
if f is not None:
passthrough = f(*key_action.args)
if self.args.debug_keyboard:
print('Keypress matched action:', f.__name__)
print('Keypress matched action:', func_name(f))
if passthrough is not True:
return True
return False

View file

@ -449,3 +449,11 @@ def abspath(x):
if q and path.startswith(q):
return True
return False
def func_name(f):
if hasattr(f, '__name__'):
return f.__name__
if hasattr(f, 'func') and hasattr(f.func, '__name__'):
return f.func.__name__
return str(f)