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.
This commit is contained in:
Victor Stinner 2011-05-19 15:18:36 +02:00
parent 35de5ac44d
commit cfd365b937
2 changed files with 38 additions and 17 deletions

View file

@ -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: