You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
sys.orig_argv is not original, at least on some systems #125006
The difference between macOS framework builds (such as our installer) and other platforms is that sys.executable is a small stub that execv-s the real interpreter that's in an embedded app bundle. Reason for that is that some system APIs, and in particular GUI frameworks, assume they are only used from app bundles.
It is probably possible to ensure sys.orig_argv[0], but getting this right in all cases including embedding in other applications is non trivial. The current behaviour is also already 5 years old at this time (the PR linked to is from 2025), which means there's a risk that changing behaviour here will break other code...
IMHO we should change the code here, although adding a note to the documentation about not using sys.executable instead of sys.orig_argv[0] could be helpful.
Activity
vstinner commentedon Oct 5, 2024
I cannot reproduce the issue on Linux.
You can also have a look at:
pkit commentedon Oct 5, 2024
Yup. As I've said it's probably OSX-specific
This one is inside venv:
pkit commentedon Oct 7, 2024
sys.executableworks well on both Linux and OSXSo, to correctly re-exec in a cross-platform way:
JacobCoffee commentedon Oct 10, 2024
here's my side
Details
ronaldoussoren commentedon Dec 18, 2025
The difference between macOS framework builds (such as our installer) and other platforms is that
sys.executableis a small stub that execv-s the real interpreter that's in an embedded app bundle. Reason for that is that some system APIs, and in particular GUI frameworks, assume they are only used from app bundles.It is probably possible to ensure
sys.orig_argv[0], but getting this right in all cases including embedding in other applications is non trivial. The current behaviour is also already 5 years old at this time (the PR linked to is from 2025), which means there's a risk that changing behaviour here will break other code...IMHO we should change the code here, although adding a note to the documentation about not using
sys.executableinstead ofsys.orig_argv[0]could be helpful.