From: Alexander Belopolsky Date: Wed, 21 Jul 2010 17:43:42 +0000 (+0000) Subject: Issue #9323: Fixed a bug in trace.py that resulted in loosing the name X-Git-Tag: v3.2a1~149 X-Git-Url: http://git.ipfire.org/gitweb.cgi?a=commitdiff_plain;h=3f8ecab589f9fab22a1d067a79aa6666568704b1;p=thirdparty%2FPython%2Fcpython.git 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 19fdbaa6a453..077cdc1e341d 100644 --- a/Lib/trace.py +++ b/Lib/trace.py @@ -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: diff --git a/Misc/NEWS b/Misc/NEWS index ebca7744a50e..ef7988f1f68f 100644 --- 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. diff --git a/Misc/maintainers.rst b/Misc/maintainers.rst index fd71f28c65de..d1d8fcc11116 100644 --- a/Misc/maintainers.rst +++ b/Misc/maintainers.rst @@ -212,7 +212,7 @@ timeit tkinter gpolo token georg.brandl tokenize -trace +trace alexander.belopolsky traceback georg.brandl tty turtle gregorlingl