summaryrefslogtreecommitdiffstats
path: root/Lib/distutils/command/build_scripts.py
diff options
context:
space:
mode:
authorVictor Stinner <victor.stinner@haypocalc.com>2011-05-19 13:18:36 (GMT)
committerVictor Stinner <victor.stinner@haypocalc.com>2011-05-19 13:18:36 (GMT)
commitcfd365b937a1edaf9da1ac61c2ca6be06fc42744 (patch)
treeef91befec6370086cffe2ea6c27b4bcee9cca138 /Lib/distutils/command/build_scripts.py
parent35de5ac44db5c42c792b71077520a6b3ef29b199 (diff)
downloadcpython-cfd365b937a1edaf9da1ac61c2ca6be06fc42744.zip
cpython-cfd365b937a1edaf9da1ac61c2ca6be06fc42744.tar.gz
cpython-cfd365b937a1edaf9da1ac61c2ca6be06fc42744.tar.bz2
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.
Diffstat (limited to 'Lib/distutils/command/build_scripts.py')
-rw-r--r--Lib/distutils/command/build_scripts.py7
1 files changed, 3 insertions, 4 deletions
diff --git a/Lib/distutils/command/build_scripts.py b/Lib/distutils/command/build_scripts.py
index a43a7c3..31be793 100644
--- a/Lib/distutils/command/build_scripts.py
+++ b/Lib/distutils/command/build_scripts.py
@@ -128,10 +128,9 @@ class build_scripts(Command):
"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: