Skip to content

gh-132414: Make invalid command-line options visible in the error mes… - #157921

Merged
serhiy-storchaka merged 2 commits into
python:mainfrom
vasiliyk:gh-132414-invalid-option
Oct 22, 2026
Merged

serhiy-storchaka merged 2 commits into
python:mainfrom
vasiliyk:gh-132414-invalid-option

Conversation

@vasiliyk

@vasiliyk vasiliyk commented Sep 21, 2026 •

Copy link
Copy Markdown
Contributor

Invalid options were printed unquoted, so a quoted argument such as python "-q -i", which a Linux shebang line produces, reported a bare dash followed by an invisible space.

The message now follows the GNU coreutils format agreed on the issue:

$ python "-q -i"
Invalid option -- ' '

$ python --foo
Invalid option '--foo'

@serhiy-storchaka

Copy link
Copy Markdown
Member

Thank you for the patch. It needs to be rebased.

The messages are also inconsistent: a short option is reported as Invalid option -- 'z', but a long option as Invalid option '--foo'.

@vasiliyk

Copy link
Copy Markdown
Contributor Author

Merged main into the branch.

Both option forms now use the same format:

./python.exe -z
Invalid option '-z'

./python.exe "-q -i"
Invalid option '- '

./python.exe --foo
Invalid option '--foo'

The inconsistency came from following the coreutils format proposed on the issue.

@serhiy-storchaka serhiy-storchaka left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM. 👍

@serhiy-storchaka
serhiy-storchaka enabled auto-merge (squash) October 22, 2026 18:38
@serhiy-storchaka
serhiy-storchaka merged commit 1bc0ed1 into python:main Oct 22, 2026
59 of 60 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants