From cfd365b937a1edaf9da1ac61c2ca6be06fc42744 Mon Sep 17 00:00:00 2001 From: Victor Stinner Date: Thu, 19 May 2011 15:18:36 +0200 Subject: 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. --- Lib/distutils/command/build_scripts.py | 7 +++---- 1 file changed, 3 insertions(+), 4 deletions(-) (limited to 'Lib/distutils/command/build_scripts.py') diff --git a/Lib/distutils/command/build_scripts.py b/Lib/distutils/command/build_scripts.py index a43a7c306a0..31be7930d73 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: -- cgit v1.2.3