Repository navigation
Conversation
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Fixes #133049
Problem
Tools/i18n/pygettext.pydiverges from GNUxgettextin two empty-input cases:No input file given —
xgettextprintsxgettext: no input file givenandTry 'xgettext --help' …with exit 1.pygettextsilently generated an emptymessages.potwith only a header.No messages to extract —
xgettextproduces no output when no strings are found.pygettextstill wrote a header-onlymessages.pot.Issue #133049 reports both;
tomasr8confirmed the first is clear and should be fixed (input file should be required), while the second is debated but the issue requests xgettext-compatible behavior.Change
In
Tools/i18n/pygettext.py:main()— after expandingargsviagetFilesForName, checkif not args:→usage(1, "pygettext: no input file given\nTry 'pygettext --help' for more information.")After visiting files, check
if not visitor.messages:→ verbose message to stderr andsys.exit(0)without creating/writing the output file (covers both-o FILEand-stdout cases). This matchesxgettext's "no output is generated if there are no messages".Keep unrelated cleanup out of this PR.
Why this approach
Minimal, xgettext-compatible, and respects the maintainer's lean: the first fix is uncontroversial and matches the exact
xgettexterror wording; the second implements the requested "no empty output" while remaining silent unless-vis given, so existing workflows that expect an empty POT can be detected via the exit and verbose hint.Testing
make checkforpygettextis covered bytest.test_tools.test_i18n(skipped in this env due to missing build dir, butgit diff --checkand manual checks pass).Documentation and release impact
Review notes
pygettextgenerates output even when there should be none #133049