Repository navigation
gh-133049: Require an input file in pygettext - #160768
Open
RajaBabu15 wants to merge 1 commit into
Open
RajaBabu15 wants to merge 1 commit into
RajaBabu15 wants to merge 1 commit into
Conversation
Like xgettext, exit with status 1 and an error message when no input file is given, instead of writing a header-only messages.pot. The check runs before the arguments are expanded, so a path that matches nothing keeps its current behaviour.
Comment on lines
+822
to
+823
| print("pygettext: no input file given\n" | ||
| "Try 'pygettext --help' for more information.", |
Member
There was a problem hiding this comment.
Suggested change
| print("pygettext: no input file given\n" | |
| "Try 'pygettext --help' for more information.", | |
| print("No input file given", |
For consistency with the other errors.
Comment on lines
+188
to
+193
| def test_missing_input_file_is_not_no_input(self): | ||
| # A path that matches nothing is not the same as no path at all. | ||
| with temp_cwd(None): | ||
| res, _ = run_python_until_end(self.script, 'does_not_exist.py') | ||
| self.assertNotIn(b'no input file given', res.err) | ||
|
|
Member
There was a problem hiding this comment.
Suggested change
| def test_missing_input_file_is_not_no_input(self): | |
| # A path that matches nothing is not the same as no path at all. | |
| with temp_cwd(None): | |
| res, _ = run_python_until_end(self.script, 'does_not_exist.py') | |
| self.assertNotIn(b'no input file given', res.err) |
This isn't really testing anything, so let's drop it.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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.
Like
xgettext,pygettextnow printspygettext: no input file givenand exits with status 1 when no input file is given, instead of silently writing a header-onlymessages.pot.This covers the first case in the issue only. As discussed there, the no-messages case keeps its current behaviour (an empty template is valid).
The check runs before
getFilesForName()expands the arguments. After expansion, a mistyped path or a directory with no.pyfiles would also be reported as "no input file", which is wrong. Those two cases keep their current behaviour, andtest_missing_input_file_is_not_no_inputpins that.Tests:
test_header,test_POT_Creation_Dateandtest_output_optionran the script without any input, so they now pass an empty file.test_no_input_fileis new. Without the change it fails; with it,test_toolsandtest_gettextpass (160 tests).I used an AI assistant (Claude Code) while preparing this change; I reviewed the diff and ran the tests myself.
pygettextgenerates output even when there should be none #133049 (pygettextgenerates output even when there should be none #133049)