SIGN IN SIGN UP

Treat `python3 -` as read-from-stdin (matches CPython) (#191)

`parseArgs` allowed `-` as the first non-flag arg but then fell into
the generic else branch that sets `result.scriptFile = arg`, so
`execute()` tried to open a file literally named `-` and returned
`python3: can't open file '-': [Errno 2] No such file or directory`
(exit 2). This breaks every CPython-conventional invocation that
passes the program on stdin via the explicit `-` sentinel:

    python3 -                    # interactive / piped stdin
    python3 - <<'EOF' ... EOF    # heredoc
    echo 'print(1)' | python3 -  # piped stdin

Per `man python3`: `-` means "read program from standard input."

Carry `-` through `parseArgs` as a sentinel (still capturing trailing
scriptArgs), and add a branch in `execute()` that routes the sentinel
to `ctx.stdin` with `argv[0] = "-"` (matching CPython). Empty stdin
runs an empty program and exits 0, matching CPython's non-interactive
behavior when no program is supplied.

Adds four regression tests covering the dash form via pipe, the dash
form via heredoc, trailing-arg propagation into `sys.argv`, and the
empty-stdin case.

Co-authored-by: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
Z
Zach Smith committed
53a81109265ea1c643161a8185f3980f5d32cea6
Parent: 6ccc35f
Committed by GitHub <noreply@github.com> on 4/30/2026, 4:47:46 PM