From d2c41b66709d9a602935441a099a61a2ac9e33e2 Mon Sep 17 00:00:00 2001 From: Martinez Date: Thu, 19 Jan 2017 11:36:22 +0100 Subject: [PATCH] improves exception output --- over/app.py | 11 +++++++---- 1 file changed, 7 insertions(+), 4 deletions(-) diff --git a/over/app.py b/over/app.py index 5034762..55e5fe1 100644 --- a/over/app.py +++ b/over/app.py @@ -741,24 +741,27 @@ class Main: # if there's a "self" in locals, we can get a hold of the method using getattr if "self" in frame.f_locals: method = getattr(frame.f_locals["self"], method_name) - method_display_name = "%s<.>.%s<.>" %(method.__self__.__class__.__name__, method_name) + method_display_name = " %s<.>.%s<.>" %(method.__self__.__class__.__name__, method_name) method_type = "method" # if it's a global function, it's likely going to be here elif method_name in frame.f_globals: method = frame.f_globals[method_name] - method_display_name = "%s<.>" %(method_name) + method_display_name = " %s<.>" %(method_name) method_type = "function" # otherwise give up else: method = None - method_display_name = "%s<.>" %(method_name) + method_display_name = "" if method_name == "": method_type = "module" + elif method_name == "": + method_type = "a generator expression" else: method_type = "unknown callable<.>" + method_display_name = " %s<.>" %(method_name) # use a docstring-provided action description if available if method and method.__doc__ and "@while" in method.__doc__: @@ -766,7 +769,7 @@ class Main: else: action = "" - tb_lines.append("%sin %s %s<.> at %s:%d," %(action, method_type, method_display_name, frame.f_code.co_filename, frame.f_lineno)) + tb_lines.append("%sin %s%s at %s:%d," %(action, method_type, method_display_name, frame.f_code.co_filename, frame.f_lineno)) if hasattr(exception, "description"): reason = ": %s<.>" %(exception.description)