-
Notifications
You must be signed in to change notification settings - Fork 54
Fix bug when writing out scripts if the python interpreter has a space #276
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: main
Are you sure you want to change the base?
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -24,6 +24,8 @@ | |
cast, | ||
) | ||
|
||
from installer.scripts import _build_shebang | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Not sure that I like importing and using a "private" function. I think a better solution would be to extract the part of the logic that is required for this use case into another function and having the There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. The part of the logic that is required for this use case is "all of it". Would it make you feel more comfortable if we remove the underscore and declare it a public function? |
||
|
||
if TYPE_CHECKING: | ||
from installer.records import RecordEntry | ||
from installer.scripts import LauncherKind, ScriptSection | ||
|
@@ -186,7 +188,7 @@ def fix_shebang(stream: BinaryIO, interpreter: str) -> Iterator[BinaryIO]: | |
if stream.read(8) == b"#!python": | ||
new_stream = io.BytesIO() | ||
# write our new shebang | ||
new_stream.write(f"#!{interpreter}\n".encode()) | ||
new_stream.write(_build_shebang(interpreter, False) + b"\n") | ||
# copy the rest of the stream | ||
stream.seek(0) | ||
stream.readline() # skip first line | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I have just noticed, that for both those cases we return exactly the same value. Can you make it into a single
if
statement with anor
?There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I have a followup commit that does this. It's not really appropriate when moving a block of code from one location to another, to also start changing the interior design of that block.