From 83102b853f2a8dad3d4c5216db39c6e65ee9ba2b Mon Sep 17 00:00:00 2001 From: Maximilian Hils Date: Wed, 27 Jul 2016 19:38:36 -0700 Subject: [PATCH] minor fixes --- mitmproxy/builtins/script.py | 4 ++-- mitmproxy/main.py | 3 ++- 2 files changed, 4 insertions(+), 3 deletions(-) diff --git a/mitmproxy/builtins/script.py b/mitmproxy/builtins/script.py index c960dd1c1..ae1d1b915 100644 --- a/mitmproxy/builtins/script.py +++ b/mitmproxy/builtins/script.py @@ -61,13 +61,13 @@ def scriptenv(path, args): try: yield except Exception: - _, _, tb = sys.exc_info() + etype, value, tb = sys.exc_info() scriptdir = os.path.dirname(os.path.abspath(path)) for i, s in enumerate(reversed(traceback.extract_tb(tb))): tb = tb.tb_next if not os.path.abspath(s[0]).startswith(scriptdir): break - ctx.log.error("Script error: %s" % "".join(traceback.format_tb(tb))) + ctx.log.error("Script error: %s" % "".join(traceback.format_exception(etype, value, tb))) finally: sys.argv = oldargs sys.path.pop() diff --git a/mitmproxy/main.py b/mitmproxy/main.py index 6d44108e1..464c38971 100644 --- a/mitmproxy/main.py +++ b/mitmproxy/main.py @@ -92,6 +92,7 @@ def mitmdump(args=None): # pragma: no cover if args.quiet: args.flow_detail = 0 + master = None try: dump_options = dump.Options(**cmdline.get_common_options(args)) dump_options.flow_detail = args.flow_detail @@ -110,7 +111,7 @@ def mitmdump(args=None): # pragma: no cover sys.exit(1) except (KeyboardInterrupt, _thread.error): pass - if master.has_errored: + if master is None or master.has_errored: print("mitmdump: errors occurred during run", file=sys.stderr) sys.exit(1)