diff Lib/distutils/core.py @ 71089:bd73edea78dc 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.
author Victor Stinner <victor.stinner@haypocalc.com>
date Thu, 30 Jun 2011 15:40:22 +0200
parents 3c9232a684ae
children 3e26c9033306
line wrap: on
line diff
--- a/Lib/distutils/core.py	Wed Jun 29 20:01:29 2011 +0200
+++ b/Lib/distutils/core.py	Thu Jun 30 15:40:22 2011 +0200
@@ -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