[Python-checkins] cpython (3.2): Issue #12451: distutils now opens the setup script in binary mode to read the

victor.stinner python-checkins at python.org
Thu Jun 30 15:42:02 CEST 2011


http://hg.python.org/cpython/rev/bd73edea78dc
changeset:   71089:bd73edea78dc
branch:      3.2
parent:      71080:450209efe272
user:        Victor Stinner <victor.stinner at haypocalc.com>
date:        Thu Jun 30 15:40:22 2011 +0200
summary:
  Issue #12451: distutils now opens the setup script in binary mode to read the
encoding cookie, instead of opening it in UTF-8.

files:
  Lib/distutils/core.py |  8 +++-----
  Misc/NEWS             |  3 +++
  2 files changed, 6 insertions(+), 5 deletions(-)


diff --git a/Lib/distutils/core.py b/Lib/distutils/core.py
--- a/Lib/distutils/core.py
+++ b/Lib/distutils/core.py
@@ -8,7 +8,8 @@
 
 __revision__ = "$Id$"
 
-import sys, os
+import os
+import sys
 
 from distutils.debug import DEBUG
 from distutils.errors import *
@@ -215,11 +216,8 @@
             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
diff --git a/Misc/NEWS b/Misc/NEWS
--- a/Misc/NEWS
+++ b/Misc/NEWS
@@ -25,6 +25,9 @@
 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

-- 
Repository URL: http://hg.python.org/cpython


More information about the Python-checkins mailing list