]> granicus.if.org Git - python/commitdiff
Merged revisions 79271 via svnmerge from
authorVictor Stinner <victor.stinner@haypocalc.com>
Mon, 22 Mar 2010 02:00:11 +0000 (02:00 +0000)
committerVictor Stinner <victor.stinner@haypocalc.com>
Mon, 22 Mar 2010 02:00:11 +0000 (02:00 +0000)
svn+ssh://pythondev@svn.python.org/python/branches/py3k

........
  r79271 | victor.stinner | 2010-03-22 02:58:35 +0100 (lun., 22 mars 2010) | 4 lines

  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.
........

Lib/profile.py
Misc/NEWS

index d969246475ba6737b84323023580fcd9260abe11..2a96ba8dfbd57641a516342b84b473c4ca0d63c6 100755 (executable)
@@ -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()
index 57d084d63ad18e143b8c71c29c23cd860ae83f2a..b8959df4e9a7368af6f4c5f27ae306058258406f 100644 (file)
--- 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