summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rwxr-xr-xLib/profile.py5
-rw-r--r--Misc/NEWS4
2 files changed, 5 insertions, 4 deletions
diff --git a/Lib/profile.py b/Lib/profile.py
index d969246..2a96ba8 100755
--- a/Lib/profile.py
+++ b/Lib/profile.py
@@ -609,11 +609,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 57d084d..b8959df 100644
--- a/Misc/NEWS
+++ b/Misc/NEWS
@@ -143,6 +143,10 @@ Core and Builtins
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 #7774: Set sys.executable to an empty string if argv[0] has been set to
an non existent program name and Python is unable to retrieve the real
program name