From 5d1442ff51293a6f9f6259e4b8c16903ae1b5c44 Mon Sep 17 00:00:00 2001 From: Stan Ulbrych Date: Mon, 19 May 2025 10:41:50 +0100 Subject: [PATCH 1/3] Use pyver --- .../Tools-Demos/2025-05-19-10-41-00.gh-issue-133319.asgss.rst | 1 + Tools/i18n/msgfmt.py | 2 +- Tools/i18n/pygettext.py | 4 ++-- 3 files changed, 4 insertions(+), 3 deletions(-) create mode 100644 Misc/NEWS.d/next/Tools-Demos/2025-05-19-10-41-00.gh-issue-133319.asgss.rst diff --git a/Misc/NEWS.d/next/Tools-Demos/2025-05-19-10-41-00.gh-issue-133319.asgss.rst b/Misc/NEWS.d/next/Tools-Demos/2025-05-19-10-41-00.gh-issue-133319.asgss.rst new file mode 100644 index 00000000000000..f56efb2195d24f --- /dev/null +++ b/Misc/NEWS.d/next/Tools-Demos/2025-05-19-10-41-00.gh-issue-133319.asgss.rst @@ -0,0 +1 @@ +Use Python versioning in :program:`msgfmt` and :program:`pygettext`. diff --git a/Tools/i18n/msgfmt.py b/Tools/i18n/msgfmt.py index cd5f1ed9f3e268..efa2101649f25e 100755 --- a/Tools/i18n/msgfmt.py +++ b/Tools/i18n/msgfmt.py @@ -34,7 +34,7 @@ from email.parser import HeaderParser import codecs -__version__ = "1.2" +__version__ = "3.15" MESSAGES = {} diff --git a/Tools/i18n/pygettext.py b/Tools/i18n/pygettext.py index f46b05067d7fde..f03d6fa9b508ae 100755 --- a/Tools/i18n/pygettext.py +++ b/Tools/i18n/pygettext.py @@ -152,7 +152,7 @@ from io import BytesIO from operator import itemgetter -__version__ = '1.5' +__version__ = '3.15' # The normal pot-file header. msgmerge and Emacs's po-mode work better if it's @@ -387,7 +387,7 @@ def unparse_spec(name, spec): parts.append(f'{pos + 1}c') else: parts.append(str(pos + 1)) - return f'{name}:{','.join(parts)}' + return f'{name}:{",".join(parts)}' def process_keywords(keywords, *, no_default_keywords): From dd500120ce7199eb18f2dd48f9fa57f5ff3d8d3c Mon Sep 17 00:00:00 2001 From: Stan Ulbrych Date: Mon, 19 May 2025 10:49:34 +0100 Subject: [PATCH 2/3] Tests --- Lib/test/test_tools/i18n_data/ascii-escapes.pot | 2 +- Lib/test/test_tools/i18n_data/comments.pot | 2 +- Lib/test/test_tools/i18n_data/custom_keywords.pot | 2 +- Lib/test/test_tools/i18n_data/docstrings.pot | 2 +- Lib/test/test_tools/i18n_data/escapes.pot | 2 +- Lib/test/test_tools/i18n_data/fileloc.pot | 2 +- Lib/test/test_tools/i18n_data/messages.pot | 2 +- Lib/test/test_tools/i18n_data/multiple_keywords.pot | 2 +- Lib/test/test_tools/test_msgfmt.py | 2 +- 9 files changed, 9 insertions(+), 9 deletions(-) diff --git a/Lib/test/test_tools/i18n_data/ascii-escapes.pot b/Lib/test/test_tools/i18n_data/ascii-escapes.pot index cc5a9f6ba619db..89ee65de23b211 100644 --- a/Lib/test/test_tools/i18n_data/ascii-escapes.pot +++ b/Lib/test/test_tools/i18n_data/ascii-escapes.pot @@ -12,7 +12,7 @@ msgstr "" "MIME-Version: 1.0\n" "Content-Type: text/plain; charset=UTF-8\n" "Content-Transfer-Encoding: 8bit\n" -"Generated-By: pygettext.py 1.5\n" +"Generated-By: pygettext.py 3.15\n" #. Special characters that are always escaped in the POT file diff --git a/Lib/test/test_tools/i18n_data/comments.pot b/Lib/test/test_tools/i18n_data/comments.pot index a1df46d453c546..babb69e46b44c9 100644 --- a/Lib/test/test_tools/i18n_data/comments.pot +++ b/Lib/test/test_tools/i18n_data/comments.pot @@ -12,7 +12,7 @@ msgstr "" "MIME-Version: 1.0\n" "Content-Type: text/plain; charset=UTF-8\n" "Content-Transfer-Encoding: 8bit\n" -"Generated-By: pygettext.py 1.5\n" +"Generated-By: pygettext.py 3.15\n" #: comments.py:4 diff --git a/Lib/test/test_tools/i18n_data/custom_keywords.pot b/Lib/test/test_tools/i18n_data/custom_keywords.pot index 03a9cba3a20b16..77c281f7264e6a 100644 --- a/Lib/test/test_tools/i18n_data/custom_keywords.pot +++ b/Lib/test/test_tools/i18n_data/custom_keywords.pot @@ -12,7 +12,7 @@ msgstr "" "MIME-Version: 1.0\n" "Content-Type: text/plain; charset=UTF-8\n" "Content-Transfer-Encoding: 8bit\n" -"Generated-By: pygettext.py 1.5\n" +"Generated-By: pygettext.py 3.15\n" #: custom_keywords.py:10 custom_keywords.py:11 diff --git a/Lib/test/test_tools/i18n_data/docstrings.pot b/Lib/test/test_tools/i18n_data/docstrings.pot index 387db2413a575f..73f349e15ad7e5 100644 --- a/Lib/test/test_tools/i18n_data/docstrings.pot +++ b/Lib/test/test_tools/i18n_data/docstrings.pot @@ -12,7 +12,7 @@ msgstr "" "MIME-Version: 1.0\n" "Content-Type: text/plain; charset=UTF-8\n" "Content-Transfer-Encoding: 8bit\n" -"Generated-By: pygettext.py 1.5\n" +"Generated-By: pygettext.py 3.15\n" #: docstrings.py:1 diff --git a/Lib/test/test_tools/i18n_data/escapes.pot b/Lib/test/test_tools/i18n_data/escapes.pot index 4dfac0f451ddcf..6db4c7f887df06 100644 --- a/Lib/test/test_tools/i18n_data/escapes.pot +++ b/Lib/test/test_tools/i18n_data/escapes.pot @@ -12,7 +12,7 @@ msgstr "" "MIME-Version: 1.0\n" "Content-Type: text/plain; charset=UTF-8\n" "Content-Transfer-Encoding: 8bit\n" -"Generated-By: pygettext.py 1.5\n" +"Generated-By: pygettext.py 3.15\n" #. Special characters that are always escaped in the POT file diff --git a/Lib/test/test_tools/i18n_data/fileloc.pot b/Lib/test/test_tools/i18n_data/fileloc.pot index dbd28687a73556..31e679b5701afd 100644 --- a/Lib/test/test_tools/i18n_data/fileloc.pot +++ b/Lib/test/test_tools/i18n_data/fileloc.pot @@ -12,7 +12,7 @@ msgstr "" "MIME-Version: 1.0\n" "Content-Type: text/plain; charset=UTF-8\n" "Content-Transfer-Encoding: 8bit\n" -"Generated-By: pygettext.py 1.5\n" +"Generated-By: pygettext.py 3.15\n" #: fileloc.py:5 fileloc.py:6 diff --git a/Lib/test/test_tools/i18n_data/messages.pot b/Lib/test/test_tools/i18n_data/messages.pot index e8167acfc0742b..e622cd0cc6df3e 100644 --- a/Lib/test/test_tools/i18n_data/messages.pot +++ b/Lib/test/test_tools/i18n_data/messages.pot @@ -12,7 +12,7 @@ msgstr "" "MIME-Version: 1.0\n" "Content-Type: text/plain; charset=UTF-8\n" "Content-Transfer-Encoding: 8bit\n" -"Generated-By: pygettext.py 1.5\n" +"Generated-By: pygettext.py 3.15\n" #: messages.py:16 diff --git a/Lib/test/test_tools/i18n_data/multiple_keywords.pot b/Lib/test/test_tools/i18n_data/multiple_keywords.pot index 954cb8e994838a..5b995adcd7c238 100644 --- a/Lib/test/test_tools/i18n_data/multiple_keywords.pot +++ b/Lib/test/test_tools/i18n_data/multiple_keywords.pot @@ -12,7 +12,7 @@ msgstr "" "MIME-Version: 1.0\n" "Content-Type: text/plain; charset=UTF-8\n" "Content-Transfer-Encoding: 8bit\n" -"Generated-By: pygettext.py 1.5\n" +"Generated-By: pygettext.py 3.15\n" #: multiple_keywords.py:3 diff --git a/Lib/test/test_tools/test_msgfmt.py b/Lib/test/test_tools/test_msgfmt.py index 7be606bbff606a..974fc9a5facbfa 100644 --- a/Lib/test/test_tools/test_msgfmt.py +++ b/Lib/test/test_tools/test_msgfmt.py @@ -253,7 +253,7 @@ def test_version(self): for option in ('--version', '-V'): res = assert_python_ok(msgfmt_py, option) out = res.out.decode('utf-8').strip() - self.assertEqual('msgfmt.py 1.2', out) + self.assertRegex(out, r'^msgfmt\.py \d+\.\d+$') def test_invalid_option(self): res = assert_python_failure(msgfmt_py, '--invalid-option') From fe1b7f0e664fa54c26ee270d9f31a7143713191c Mon Sep 17 00:00:00 2001 From: Stan Ulbrych <89152624+StanFromIreland@users.noreply.github.com> Date: Wed, 28 May 2025 14:38:10 +0100 Subject: [PATCH 3/3] Add explanation --- Tools/i18n/pygettext.py | 1 + 1 file changed, 1 insertion(+) diff --git a/Tools/i18n/pygettext.py b/Tools/i18n/pygettext.py index f03d6fa9b508ae..5a86456c9c6058 100755 --- a/Tools/i18n/pygettext.py +++ b/Tools/i18n/pygettext.py @@ -152,6 +152,7 @@ from io import BytesIO from operator import itemgetter +# Update this to the current python version when modifying this script. __version__ = '3.15'