diff Lib/distutils/command/build_scripts.py @ 70199:cc5cfeaa4a8d

Issue #10419, issue #6011: port 6ad356525381 fix from distutils to packaging build_scripts command of packaging now handles correctly non-ASCII path (path to the Python executable). Open and write the script in binary mode, but ensure that the shebang is decodable from UTF-8 and from the encoding of the script.
author Victor Stinner <victor.stinner@haypocalc.com>
date Thu, 19 May 2011 15:18:36 +0200
parents af18b150065e
children 6b9f0a6efaeb
line wrap: on
line diff
--- a/Lib/distutils/command/build_scripts.py	Thu May 19 15:09:57 2011 +0200
+++ b/Lib/distutils/command/build_scripts.py	Thu May 19 15:18:36 2011 +0200
@@ -128,10 +128,9 @@
                             "The shebang ({!r}) is not decodable "
                             "from the script encoding ({})"
                             .format(shebang, encoding))
-                    outf = open(outfile, "wb")
-                    outf.write(shebang)
-                    outf.writelines(f.readlines())
-                    outf.close()
+                    with open(outfile, "wb") as outf:
+                        outf.write(shebang)
+                        outf.writelines(f.readlines())
                 if f:
                     f.close()
             else: