summaryrefslogtreecommitdiffstats
path: root/Lib/distutils/core.py
diff options
context:
space:
mode:
authorVictor Stinner <victor.stinner@haypocalc.com>2011-06-30 13:40:22 (GMT)
committerVictor Stinner <victor.stinner@haypocalc.com>2011-06-30 13:40:22 (GMT)
commitdc9b1ea02eba907ae48cea682a49c5df34d0e19e (patch)
tree06577cedfbada2e5fbc19f5e7b91fb29541a42a8 /Lib/distutils/core.py
parentfcc2a21fae20b312e913a26121a12752ba768ad1 (diff)
downloadcpython-dc9b1ea02eba907ae48cea682a49c5df34d0e19e.zip
cpython-dc9b1ea02eba907ae48cea682a49c5df34d0e19e.tar.gz
cpython-dc9b1ea02eba907ae48cea682a49c5df34d0e19e.tar.bz2
Issue #12451: distutils now opens the setup script in binary mode to read the
encoding cookie, instead of opening it in UTF-8.
Diffstat (limited to 'Lib/distutils/core.py')
-rw-r--r--Lib/distutils/core.py8
1 files changed, 3 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