Skip to content

Commit

Permalink
fix: Don't crash when trying to update the shebang in a binary script (
Browse files Browse the repository at this point in the history
  • Loading branch information
pawamoy committed Feb 14, 2023
1 parent 29cfff9 commit 72c82f5
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 3 deletions.
1 change: 1 addition & 0 deletions news/1709.bugfix.md
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
Don't crash when trying to update the shebang in a binary script.
6 changes: 3 additions & 3 deletions src/pdm/models/environment.py
Original file line number Diff line number Diff line change
Expand Up @@ -63,10 +63,10 @@ def _replace_shebang(contents: bytes, new_executable: bytes) -> bytes:
match = re.search(_complex_shebang_re, contents, flags=re.M)
if match:
return contents.replace(match.group(1), new_executable, 1)
else:
match = re.search(_simple_shebang_re, contents, flags=re.M)
assert match is not None
match = re.search(_simple_shebang_re, contents, flags=re.M)
if match:
return contents.replace(match.group(1), new_executable, 1)
return contents


class PackageFinder(unearth.PackageFinder):
Expand Down

0 comments on commit 72c82f5

Please sign in to comment.