Issue #9323: Fixed a bug in trace.py that resulted in loosing the name
of the script being traced.  Patch by Eli Bendersky.
diff --git a/Lib/trace.py b/Lib/trace.py
index 19fdbaa..077cdc1 100644
--- a/Lib/trace.py
+++ b/Lib/trace.py
@@ -797,12 +797,9 @@
                   ignoredirs=ignore_dirs, infile=counts_file,
                   outfile=counts_file, timing=timing)
         try:
-            fp = open(progname)
-            try:
-                script = fp.read()
-            finally:
-                fp.close()
-            t.run('exec(%r)' % (script,))
+            with open(progname) as fp:
+                code = compile(fp.read(), progname, 'exec')
+            t.run(code)
         except IOError as err:
             _err_exit("Cannot run file %r because: %s" % (sys.argv[0], err))
         except SystemExit: