From ed0342c2614addfdbc174e511d6ad91426d66be0 Mon Sep 17 00:00:00 2001 From: Stan Ulbrych Date: Sat, 29 Mar 2025 16:23:36 +0000 Subject: [PATCH 1/5] Filter out POT-Creation-Date --- Lib/test/test_tools/msgfmt_data/general.json | 2 +- Lib/test/test_tools/msgfmt_data/general.mo | Bin 712 -> 670 bytes ...25-03-29-16-20-00.gh-issue-131852.afuefb.rst | 2 ++ Tools/i18n/msgfmt.py | 12 ++++++++++-- 4 files changed, 13 insertions(+), 3 deletions(-) create mode 100644 Misc/NEWS.d/next/Tools-Demos/2025-03-29-16-20-00.gh-issue-131852.afuefb.rst diff --git a/Lib/test/test_tools/msgfmt_data/general.json b/Lib/test/test_tools/msgfmt_data/general.json index 8ceb34cd17fb07..0166ccb5b4a0bd 100644 --- a/Lib/test/test_tools/msgfmt_data/general.json +++ b/Lib/test/test_tools/msgfmt_data/general.json @@ -1,7 +1,7 @@ [ [ "", - "Project-Id-Version: PACKAGE VERSION\nPOT-Creation-Date: 2024-10-26 18:06+0200\nPO-Revision-Date: YEAR-MO-DA HO:MI+ZONE\nLast-Translator: FULL NAME \nLanguage-Team: LANGUAGE \nMIME-Version: 1.0\nContent-Type: text/plain; charset=UTF-8\nContent-Transfer-Encoding: 8bit\n" + "Project-Id-Version: PACKAGE VERSION\nPO-Revision-Date: YEAR-MO-DA HO:MI+ZONE\nLast-Translator: FULL NAME \nLanguage-Team: LANGUAGE \nMIME-Version: 1.0\nContent-Type: text/plain; charset=UTF-8\nContent-Transfer-Encoding: 8bit" ], [ "\n newlines \n", diff --git a/Lib/test/test_tools/msgfmt_data/general.mo b/Lib/test/test_tools/msgfmt_data/general.mo index 44b7363071a98bfe61eadc6adb0b434f1fd36125..cb20fd4c90d9816306097e735801d00e27b3415a 100644 GIT binary patch delta 87 zcmX@XI*)Ziit85!1_m8Q1_nMLt;oc{zyqWWfV2pZwguAiKspFY7XfKzAb%2+o(837 QOzrC?-WWTI Date: Sat, 29 Mar 2025 16:40:20 +0000 Subject: [PATCH 2/5] Use re to keep final '\n' --- Lib/test/test_tools/msgfmt_data/general.json | 2 +- Lib/test/test_tools/msgfmt_data/general.mo | Bin 670 -> 671 bytes Tools/i18n/msgfmt.py | 10 ++++++---- 3 files changed, 7 insertions(+), 5 deletions(-) diff --git a/Lib/test/test_tools/msgfmt_data/general.json b/Lib/test/test_tools/msgfmt_data/general.json index 0166ccb5b4a0bd..0586113985a112 100644 --- a/Lib/test/test_tools/msgfmt_data/general.json +++ b/Lib/test/test_tools/msgfmt_data/general.json @@ -1,7 +1,7 @@ [ [ "", - "Project-Id-Version: PACKAGE VERSION\nPO-Revision-Date: YEAR-MO-DA HO:MI+ZONE\nLast-Translator: FULL NAME \nLanguage-Team: LANGUAGE \nMIME-Version: 1.0\nContent-Type: text/plain; charset=UTF-8\nContent-Transfer-Encoding: 8bit" + "Project-Id-Version: PACKAGE VERSION\nPO-Revision-Date: YEAR-MO-DA HO:MI+ZONE\nLast-Translator: FULL NAME \nLanguage-Team: LANGUAGE \nMIME-Version: 1.0\nContent-Type: text/plain; charset=UTF-8\nContent-Transfer-Encoding: 8bit\n" ], [ "\n newlines \n", diff --git a/Lib/test/test_tools/msgfmt_data/general.mo b/Lib/test/test_tools/msgfmt_data/general.mo index cb20fd4c90d9816306097e735801d00e27b3415a..ee905cbb3ec58db04c2f2fca5f67e15ce7a852c9 100644 GIT binary patch delta 86 zcmbQoI-hkyitASf1_m8Q1_nMLt;EE@zyqWWfwTyawgb}gKsp#o7XxW#Ab&EHo(`pF PZ(Lc<$jCKWfvFAvwM7b2 delta 84 zcmbQwI*)Ziit85!1_m8Q1_nMLt;oc{zyqWWfV2pZwguAiKspFY7XfKzAb%2+o(837 NZCqK-I9ZXY4gjHb3O@h< diff --git a/Tools/i18n/msgfmt.py b/Tools/i18n/msgfmt.py index 9183c60dd7fdc1..d18784ad94afbb 100755 --- a/Tools/i18n/msgfmt.py +++ b/Tools/i18n/msgfmt.py @@ -161,10 +161,12 @@ def make(filename, outfile): if not msgid: # Filter out POT-Creation-Date # See issue #131852 - msgstr = "\n".join( - line - for line in msgstr.decode(encoding).splitlines() - if not line.startswith("POT-Creation-Date:") + import re + msgstr = re.sub( + r"^POT-Creation-Date:.*(?:\n|$)", + "", + msgstr.decode(encoding), + flags=re.MULTILINE, ).encode(encoding) # See whether there is an encoding declaration From e0734a67fc25532d4aeea615d4523fec221c3124 Mon Sep 17 00:00:00 2001 From: Stan Ulbrych Date: Sat, 29 Mar 2025 18:00:59 +0000 Subject: [PATCH 3/5] simplify --- Tools/i18n/msgfmt.py | 9 ++------- 1 file changed, 2 insertions(+), 7 deletions(-) diff --git a/Tools/i18n/msgfmt.py b/Tools/i18n/msgfmt.py index d18784ad94afbb..87e10ab46c1a26 100755 --- a/Tools/i18n/msgfmt.py +++ b/Tools/i18n/msgfmt.py @@ -161,13 +161,8 @@ def make(filename, outfile): if not msgid: # Filter out POT-Creation-Date # See issue #131852 - import re - msgstr = re.sub( - r"^POT-Creation-Date:.*(?:\n|$)", - "", - msgstr.decode(encoding), - flags=re.MULTILINE, - ).encode(encoding) + msgstr = ''.join(line for line in msgstr.decode(encoding).splitlines(True) + if 'POT-Creation-Date' not in line).encode(encoding) # See whether there is an encoding declaration p = HeaderParser() From 2707ba6154a4ecdc35fd9eec7896716d3aee254d Mon Sep 17 00:00:00 2001 From: Stan Ulbrych <89152624+StanFromIreland@users.noreply.github.com> Date: Sat, 29 Mar 2025 21:04:16 +0000 Subject: [PATCH 4/5] Update Tools/i18n/msgfmt.py Co-authored-by: Tomas R. --- Tools/i18n/msgfmt.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/Tools/i18n/msgfmt.py b/Tools/i18n/msgfmt.py index 87e10ab46c1a26..1d306c778320f5 100755 --- a/Tools/i18n/msgfmt.py +++ b/Tools/i18n/msgfmt.py @@ -161,8 +161,8 @@ def make(filename, outfile): if not msgid: # Filter out POT-Creation-Date # See issue #131852 - msgstr = ''.join(line for line in msgstr.decode(encoding).splitlines(True) - if 'POT-Creation-Date' not in line).encode(encoding) + msgstr = b''.join(line for line in msgstr.splitlines(True) + if not line.startswith(b'POT-Creation-Date')) # See whether there is an encoding declaration p = HeaderParser() From 5368a977d457d64974479d097fd03ff107e6c5cc Mon Sep 17 00:00:00 2001 From: Stan Ulbrych <89152624+StanFromIreland@users.noreply.github.com> Date: Sat, 5 Apr 2025 19:31:48 +0100 Subject: [PATCH 5/5] Update Tools/i18n/msgfmt.py Co-authored-by: Serhiy Storchaka --- Tools/i18n/msgfmt.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Tools/i18n/msgfmt.py b/Tools/i18n/msgfmt.py index 1d306c778320f5..cd5f1ed9f3e268 100755 --- a/Tools/i18n/msgfmt.py +++ b/Tools/i18n/msgfmt.py @@ -162,7 +162,7 @@ def make(filename, outfile): # Filter out POT-Creation-Date # See issue #131852 msgstr = b''.join(line for line in msgstr.splitlines(True) - if not line.startswith(b'POT-Creation-Date')) + if not line.startswith(b'POT-Creation-Date:')) # See whether there is an encoding declaration p = HeaderParser()