summaryrefslogtreecommitdiffstats
path: root/Lib/profile.py
diff options
context:
space:
mode:
authorVictor Stinner <victor.stinner@haypocalc.com>2010-03-22 01:58:35 (GMT)
committerVictor Stinner <victor.stinner@haypocalc.com>2010-03-22 01:58:35 (GMT)
commite3a1f6d3b7850c1fdca803d9530ded2315297de3 (patch)
tree2313e93fb354f1dc7248d936eb99dd85fc979aae /Lib/profile.py
parent434ae7703d08ab47dab0fcf9f382bbe7ae2996a1 (diff)
downloadcpython-e3a1f6d3b7850c1fdca803d9530ded2315297de3.zip
cpython-e3a1f6d3b7850c1fdca803d9530ded2315297de3.tar.gz
cpython-e3a1f6d3b7850c1fdca803d9530ded2315297de3.tar.bz2
Issue #4282: Fix the main function of the profile module for a non-ASCII
script, open the file in binary mode and not in text mode with the default (utf8) encoding.
Diffstat (limited to 'Lib/profile.py')
-rwxr-xr-xLib/profile.py5
1 files changed, 1 insertions, 4 deletions
diff --git a/Lib/profile.py b/Lib/profile.py
index a09fffe..8d68d17 100755
--- a/Lib/profile.py
+++ b/Lib/profile.py
@@ -602,11 +602,8 @@ def main():
if (len(args) > 0):
sys.argv[:] = args
sys.path.insert(0, os.path.dirname(sys.argv[0]))
- fp = open(sys.argv[0])
- try:
+ with open(sys.argv[0], 'rb') as fp:
script = fp.read()
- finally:
- fp.close()
run('exec(%r)' % script, options.outfile, options.sort)
else:
parser.print_usage()