https://github.com/python/cpython/commit/9d1e668e6f40967dda5cbb1ce298bf0dff2d807c
commit: 9d1e668e6f40967dda5cbb1ce298bf0dff2d807c
branch: main
author: Tomas R. <[email protected]>
committer: serhiy-storchaka <[email protected]>
date: 2025-02-14T11:34:09+02:00
summary:

gh-129911: pygettext: Fix the keyword entry in help output (GH-129914)

files:
A Misc/NEWS.d/next/Tools-Demos/2025-02-09-20-29-06.gh-issue-129911.uMFtf1.rst
M Lib/test/test_tools/test_i18n.py
M Tools/i18n/pygettext.py

diff --git a/Lib/test/test_tools/test_i18n.py b/Lib/test/test_tools/test_i18n.py
index d23479104d438d..f5aba31ed42c10 100644
--- a/Lib/test/test_tools/test_i18n.py
+++ b/Lib/test/test_tools/test_i18n.py
@@ -413,6 +413,12 @@ def test_files_list(self):
             self.assertIn(f'msgid "{text2}"', data)
             self.assertNotIn(text3, data)
 
+    def test_help_text(self):
+        """Test that the help text is displayed."""
+        res = assert_python_ok(self.script, '--help')
+        self.assertEqual(res.out, b'')
+        self.assertIn(b'pygettext -- Python equivalent of xgettext(1)', 
res.err)
+
     def test_error_messages(self):
         """Test that pygettext outputs error messages to stderr."""
         stderr = self.get_stderr(dedent('''\
diff --git 
a/Misc/NEWS.d/next/Tools-Demos/2025-02-09-20-29-06.gh-issue-129911.uMFtf1.rst 
b/Misc/NEWS.d/next/Tools-Demos/2025-02-09-20-29-06.gh-issue-129911.uMFtf1.rst
new file mode 100644
index 00000000000000..1903af78128ffc
--- /dev/null
+++ 
b/Misc/NEWS.d/next/Tools-Demos/2025-02-09-20-29-06.gh-issue-129911.uMFtf1.rst
@@ -0,0 +1 @@
+Fix the keyword entry in the help output of :program:`pygettext`.
diff --git a/Tools/i18n/pygettext.py b/Tools/i18n/pygettext.py
index 4720aecbdc515a..4177d46048f9b9 100755
--- a/Tools/i18n/pygettext.py
+++ b/Tools/i18n/pygettext.py
@@ -67,7 +67,8 @@
     -k word
     --keyword=word
         Keywords to look for in addition to the default set, which are:
-        %(DEFAULTKEYWORDS)s
+        _, gettext, ngettext, pgettext, npgettext, dgettext, dngettext,
+        dpgettext, and dnpgettext.
 
         You can have multiple -k flags on the command line.
 
@@ -169,7 +170,7 @@
 
 
 def usage(code, msg=''):
-    print(__doc__ % globals(), file=sys.stderr)
+    print(__doc__, file=sys.stderr)
     if msg:
         print(msg, file=sys.stderr)
     sys.exit(code)

_______________________________________________
Python-checkins mailing list -- [email protected]
To unsubscribe send an email to [email protected]
https://mail.python.org/mailman3/lists/python-checkins.python.org/
Member address: [email protected]

Reply via email to