]> granicus.if.org Git - python/commitdiff
Issue #12451: distutils now opens the setup script in binary mode to read the
authorVictor Stinner <victor.stinner@haypocalc.com>
Thu, 30 Jun 2011 13:40:22 +0000 (15:40 +0200)
committerVictor Stinner <victor.stinner@haypocalc.com>
Thu, 30 Jun 2011 13:40:22 +0000 (15:40 +0200)
encoding cookie, instead of opening it in UTF-8.

Lib/distutils/core.py
Misc/NEWS

index fd2a43d7d288191ed80f3ddf2b38475d397a97cb..c0a04de3af04cb13c7f049ce10e58f2d53d3218d 100644 (file)
@@ -8,7 +8,8 @@ really defined in distutils.dist and distutils.cmd.
 
 __revision__ = "$Id$"
 
-import sys, os
+import os
+import sys
 
 from distutils.debug import DEBUG
 from distutils.errors import *
@@ -215,11 +216,8 @@ def run_setup (script_name, script_args=None, stop_after="run"):
             sys.argv[0] = script_name
             if script_args is not None:
                 sys.argv[1:] = script_args
-            f = open(script_name)
-            try:
+            with open(script_name, 'rb') as f:
                 exec(f.read(), g, l)
-            finally:
-                f.close()
         finally:
             sys.argv = save_argv
             _setup_stop_after = None
index 51a7d57a3e836f8d3c12518068e75167dbe7fa41..9419f67b246dc1f574bb809c7fbc0ebd19e77049 100644 (file)
--- a/Misc/NEWS
+++ b/Misc/NEWS
@@ -25,6 +25,9 @@ Core and Builtins
 Library
 -------
 
+- Issue #12451: distutils now opens the setup script in binary mode to read the
+  encoding cookie, instead of opening it in UTF-8.
+
 - Issue #9516: On Mac OS X, change Distutils to no longer globally attempt to
   check or set the MACOSX_DEPLOYMENT_TARGET environment variable for the
   interpreter process.  This could cause failures in non-Distutils subprocesses