Fix type of stack argument for utils.message
This commit is contained in:
parent
569bb0fa09
commit
8725ac6e66
@ -34,15 +34,10 @@ def _log_stack(typ, stack):
|
|||||||
|
|
||||||
Args:
|
Args:
|
||||||
typ: The type of the message (str)
|
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:
|
lines = stack.splitlines()
|
||||||
# traceback.format_exc() produces a list of strings, while
|
stack_text = '\n'.join(line.rstrip() for line in lines)
|
||||||
# traceback.format_stack() produces a single string...
|
|
||||||
stack = stack.splitlines()
|
|
||||||
except AttributeError:
|
|
||||||
pass
|
|
||||||
stack_text = '\n'.join(line.rstrip() for line in stack)
|
|
||||||
log.message.debug("Stack for {} message:\n{}".format(typ, stack_text))
|
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
|
replace: Replace existing messages with replace=True
|
||||||
"""
|
"""
|
||||||
if stack is None:
|
if stack is None:
|
||||||
stack = traceback.format_stack()
|
stack = ''.join(traceback.format_stack())
|
||||||
typ = 'error'
|
typ = 'error'
|
||||||
else:
|
else:
|
||||||
typ = 'error (from exception)'
|
typ = 'error (from exception)'
|
||||||
@ -71,7 +66,7 @@ def warning(message, *, replace=False):
|
|||||||
message: The message to show
|
message: The message to show
|
||||||
replace: Replace existing messages with replace=True
|
replace: Replace existing messages with replace=True
|
||||||
"""
|
"""
|
||||||
_log_stack('warning', traceback.format_stack())
|
_log_stack('warning', ''.join(traceback.format_stack()))
|
||||||
log.message.warning(message)
|
log.message.warning(message)
|
||||||
global_bridge.show(usertypes.MessageLevel.warning, message, replace)
|
global_bridge.show(usertypes.MessageLevel.warning, message, replace)
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user