Issue #9323: Fixed a bug in trace.py that resulted in loosing the name
authorAlexander Belopolsky <alexander.belopolsky@gmail.com>
Wed, 21 Jul 2010 17:43:42 +0000 (17:43 +0000)
committerAlexander Belopolsky <alexander.belopolsky@gmail.com>
Wed, 21 Jul 2010 17:43:42 +0000 (17:43 +0000)
of the script being traced.  Patch by Eli Bendersky.

Lib/trace.py
Misc/NEWS
Misc/maintainers.rst

index 19fdbaa6a453914b56421b1caee94cec23d52b0e..077cdc1e341dcc42f13e4b5a0944ff7ba0246595 100644 (file)
@@ -797,12 +797,9 @@ def main(argv=None):
                   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:
index ebca7744a50e244d1ec9bcab6d7aafd0b50dd27c..ef7988f1f68f942fb7bbc0137f4497ae8e58d6c2 100644 (file)
--- a/Misc/NEWS
+++ b/Misc/NEWS
@@ -473,6 +473,9 @@ C-API
 Library
 -------
 
+- Issue #9323: Fixed a bug in trace.py that resulted in loosing the
+  name of the script being traced.  Patch by Eli Bendersky.
+
 - Issue #9282: Fixed --listfuncs option of trace.py.  Thanks Eli
   Bendersky for the patch.
 
index fd71f28c65debc6786ad198eaee7eda2ffa1d080..d1d8fcc11116de9bd2ded320dd6b225d2b25b3bf 100644 (file)
@@ -212,7 +212,7 @@ timeit
 tkinter             gpolo
 token               georg.brandl
 tokenize
-trace
+trace               alexander.belopolsky
 traceback           georg.brandl
 tty
 turtle              gregorlingl