summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorVictor Stinner <victor.stinner@haypocalc.com>2011-06-30 13:41:56 (GMT)
committerVictor Stinner <victor.stinner@haypocalc.com>2011-06-30 13:41:56 (GMT)
commit0b5e049ea01f7b0506a8fe596f1d79e2350fc9a4 (patch)
tree36dbbe0a533c895b49e70589838319a59bbb16cd
parent844315c7514dab785ce7d2e0912645f3fab9d306 (diff)
parentdc9b1ea02eba907ae48cea682a49c5df34d0e19e (diff)
downloadcpython-0b5e049ea01f7b0506a8fe596f1d79e2350fc9a4.zip
cpython-0b5e049ea01f7b0506a8fe596f1d79e2350fc9a4.tar.gz
cpython-0b5e049ea01f7b0506a8fe596f1d79e2350fc9a4.tar.bz2
(merge 3.2) Issue #12451: distutils now opens the setup script in binary mode
to read the encoding cookie, instead of opening it in UTF-8.
-rw-r--r--Lib/distutils/core.py8
-rw-r--r--Misc/NEWS3
2 files changed, 6 insertions, 5 deletions
diff --git a/Lib/distutils/core.py b/Lib/distutils/core.py
index fd2a43d..c0a04de 100644
--- a/Lib/distutils/core.py
+++ b/Lib/distutils/core.py
@@ -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
diff --git a/Misc/NEWS b/Misc/NEWS
index ce31628..aa09eee 100644
--- a/Misc/NEWS
+++ b/Misc/NEWS
@@ -200,6 +200,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