From 62d705535bbcff35a9197ec45a9d4c7cb89fe171 Mon Sep 17 00:00:00 2001 From: jmw327 Date: Thu, 19 Oct 2017 21:41:07 -0500 Subject: [PATCH] try file first, then code --- test.py | 3 +++ traceface | 2 ++ 2 files changed, 5 insertions(+) diff --git a/test.py b/test.py index fa0179f..dfbab67 100644 --- a/test.py +++ b/test.py @@ -9,3 +9,6 @@ def shout(s): def say(s): print(s) + +if __name__ == '__main__': + hello() diff --git a/traceface b/traceface index d138b22..6e8a507 100755 --- a/traceface +++ b/traceface @@ -45,6 +45,8 @@ class Tracer: def run(self, code, run_globals=None): sys.settrace(self.trace_dispatch) try: + exec(compile(open(code, "rb").read(), code, 'exec'), globals()) + except FileNotFoundError: exec(code, run_globals) finally: sys.settrace(None)