Mercurial > cpython-lru_cache-weakref
diff Lib/trace.py @ 63132:4545ff5061b7
Issue #9323: Fixed a bug in trace.py that resulted in loosing the name
of the script being traced. Patch by Eli Bendersky.
| author | Alexander Belopolsky <alexander.belopolsky@gmail.com> |
|---|---|
| date | Wed, 21 Jul 2010 17:43:42 +0000 |
| parents | a14a78692c7a |
| children | 31f4c4b6c445 |
line wrap: on
line diff
--- a/Lib/trace.py Wed Jul 21 16:41:31 2010 +0000 +++ b/Lib/trace.py Wed Jul 21 17:43:42 2010 +0000 @@ -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:
