diff options
author | Alexander Belopolsky <alexander.belopolsky@gmail.com> | 2010-07-21 17:43:42 (GMT) |
---|---|---|
committer | Alexander Belopolsky <alexander.belopolsky@gmail.com> | 2010-07-21 17:43:42 (GMT) |
commit | 3f8ecab589f9fab22a1d067a79aa6666568704b1 (patch) | |
tree | e6638915246c1912d158bad234404f587321df9c /Lib/trace.py | |
parent | 8cb6dbf1b9d606de4ef1b3c4141ae186d32492db (diff) | |
download | cpython-3f8ecab589f9fab22a1d067a79aa6666568704b1.zip cpython-3f8ecab589f9fab22a1d067a79aa6666568704b1.tar.gz cpython-3f8ecab589f9fab22a1d067a79aa6666568704b1.tar.bz2 |
Issue #9323: Fixed a bug in trace.py that resulted in loosing the name
of the script being traced. Patch by Eli Bendersky.
Diffstat (limited to 'Lib/trace.py')
-rw-r--r-- | Lib/trace.py | 9 |
1 files changed, 3 insertions, 6 deletions
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 @@ 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: |