From 8725ac6e667fe106edf446a5e61e282024ba32ac Mon Sep 17 00:00:00 2001 From: Florian Bruhin Date: Fri, 30 Nov 2018 12:49:57 +0100 Subject: [PATCH] Fix type of stack argument for utils.message --- qutebrowser/utils/message.py | 15 +++++---------- 1 file changed, 5 insertions(+), 10 deletions(-) diff --git a/qutebrowser/utils/message.py b/qutebrowser/utils/message.py index 9dc8d7411..035cc1c71 100644 --- a/qutebrowser/utils/message.py +++ b/qutebrowser/utils/message.py @@ -34,15 +34,10 @@ def _log_stack(typ, stack): Args: typ: The type of the message (str) - stack: The stack as an iterable of strings or a single string + stack: The stacktrace as a string. """ - try: - # traceback.format_exc() produces a list of strings, while - # traceback.format_stack() produces a single string... - stack = stack.splitlines() - except AttributeError: - pass - stack_text = '\n'.join(line.rstrip() for line in stack) + lines = stack.splitlines() + stack_text = '\n'.join(line.rstrip() for line in lines) log.message.debug("Stack for {} message:\n{}".format(typ, stack_text)) @@ -55,7 +50,7 @@ def error(message, *, stack=None, replace=False): replace: Replace existing messages with replace=True """ if stack is None: - stack = traceback.format_stack() + stack = ''.join(traceback.format_stack()) typ = 'error' else: typ = 'error (from exception)' @@ -71,7 +66,7 @@ def warning(message, *, replace=False): message: The message to show replace: Replace existing messages with replace=True """ - _log_stack('warning', traceback.format_stack()) + _log_stack('warning', ''.join(traceback.format_stack())) log.message.warning(message) global_bridge.show(usertypes.MessageLevel.warning, message, replace)