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
argparse reports python -m for programmatic module-as-main execution #155009
This intentionally executes an importable module as __main__, while preserving the user-facing executable filename in sys.argv[0].
Python 3.14 instead reports a synthetic python -m module command that the user did not invoke.
This is an uncommon setup, but other executable loaders or embedded runtimes may use the same pattern.
The module is deliberately executed as __main__, so its populated __main__.__spec__ is expected.
The issue is that this alone does not prove the interpreter was invoked with -m.
A potential solution that preserves the intent of the original change is consulting sys.orig_argv to confirm an actual -m <module> invocation.
Activity
johnslavik commentedon Jul 31, 2026
cc @savannahostrowski
itamaro commentedon Aug 1, 2026
fwiw, facebookincubator/MetaPython@6e8b452 is the patch I applied to our fork
Merge branch 'pythongh-155009-argparse-prog' of https://github.com/sa…
GH-155009: Preserve argparse prog for programmatic module-as-main exe…
[3.14] GH-155009: Preserve argparse prog for programmatic module-as-m…
[3.15] GH-155009: Preserve argparse prog for programmatic module-as-m…
[3.14] pythonGH-155009: Preserve argparse prog for programmatic modul…
gh-155009: Fix argparse test on non-UTF-8 locales like Raspbian (#155227
[3.14] gh-155009: Fix argparse test on non-UTF-8 locales like Raspbian (
[3.15] gh-155009: Fix argparse test on non-UTF-8 locales like Raspbian (
Drop argparse.prog file name patch in favor of upstream fix
pythonGH-155009: Preserve argparse prog for programmatic module-as-ma…
pythongh-155009: Fix argparse test on non-UTF-8 locales like Raspbian (…