-
Notifications
You must be signed in to change notification settings - Fork 2.3k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Fix incorrect sys.argv[0] path when calling project scripts (#6737)
Co-authored-by: Christopher Dignam <[email protected]> Co-authored-by: Randy Döring <[email protected]>
- Loading branch information
1 parent
e1504ed
commit 33242c2
Showing
4 changed files
with
81 additions
and
1 deletion.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,23 @@ | ||
from __future__ import annotations | ||
|
||
import sys | ||
|
||
from pathlib import Path | ||
|
||
|
||
def main() -> int: | ||
path = Path(sys.argv[0]) | ||
if sys.argv[1] == "absolute": | ||
if not path.is_absolute(): | ||
raise RuntimeError(f"sys.argv[0] is not an absolute path: {path}") | ||
if not path.exists(): | ||
raise RuntimeError(f"sys.argv[0] does not exist: {path}") | ||
else: | ||
if path.is_absolute(): | ||
raise RuntimeError(f"sys.argv[0] is an absolute path: {path}") | ||
|
||
return 0 | ||
|
||
|
||
if __name__ == "__main__": | ||
raise sys.exit(main()) |