Open A2uria opened 3 weeks ago
Or maybe just do the equivalent of result = b'#!' + executable + post_interp + os.linesep.encode('utf-8')
in _build_shebang()
?
Or maybe just do the equivalent of
result = b'#!' + executable + post_interp + os.linesep.encode('utf-8')
in_build_shebang()
?
os.linesep.encode('utf-8')
is \r\n
on windows but \n
is enough.
Maybe we can ensure the shebang ends in \n
. This should work on both windows and linux.
It seems that os.linesep
is \n
on macos, so it should work either.
This should work.
if not shebang.endswith(b'\n'):
shebang += b'\n'
Or just hardcode a newline here in case of contrived shebang and remove the check, since _build_shebang()
is always called before _write_script()
.
I suppose that _write_script()
is private, so removing the check is ok since there is a hardcoded terminating newline in _build_shebang()
. If this is not expected, the following code can be used instead.
if not shebang.endswith(b'\n'):
shebang += b'\n'
ScriptMaker._build_shebang
hardcoded ab'\n'
.https://github.com/pypa/distlib/blob/888c48b56886b03398646be1217508830427bd75/distlib/scripts.py#L169-L170
However,
ScriptMaker._write_script
will check forb'\r\n'
, which is non existant.https://github.com/pypa/distlib/blob/888c48b56886b03398646be1217508830427bd75/distlib/scripts.py#L255-L257
Remove the hardcoded
b'\n'
and letScriptMaker._write_script
to generate newline for shebang is more universal but check for a singleb'\n'
on windows might be better.