From: Victor Stinner Date: Mon, 22 Mar 2010 01:58:35 +0000 (+0000) Subject: Issue #4282: Fix the main function of the profile module for a non-ASCII X-Git-Tag: v3.2a1~1349 X-Git-Url: https://granicus.if.org/sourcecode?a=commitdiff_plain;h=e3a1f6d3b7850c1fdca803d9530ded2315297de3;p=python 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. --- diff --git a/Lib/profile.py b/Lib/profile.py index a09fffea43..8d68d17cbe 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() diff --git a/Misc/NEWS b/Misc/NEWS index c287e0c291..cfe45fb666 100644 --- a/Misc/NEWS +++ b/Misc/NEWS @@ -285,6 +285,10 @@ C-API Library ------- +- 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. + - Issue #8179: Fix macpath.realpath() on a non-existing path. - Issue #8024: Update the Unicode database to 5.2.