Skip to content

Commit adcd533

Browse files
Use re to keep final '\n'
1 parent ed0342c commit adcd533

File tree

3 files changed

+7
-5
lines changed

3 files changed

+7
-5
lines changed

Lib/test/test_tools/msgfmt_data/general.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
[
22
[
33
"",
4-
"Project-Id-Version: PACKAGE VERSION\nPO-Revision-Date: YEAR-MO-DA HO:MI+ZONE\nLast-Translator: FULL NAME <EMAIL@ADDRESS>\nLanguage-Team: LANGUAGE <[email protected]>\nMIME-Version: 1.0\nContent-Type: text/plain; charset=UTF-8\nContent-Transfer-Encoding: 8bit"
4+
"Project-Id-Version: PACKAGE VERSION\nPO-Revision-Date: YEAR-MO-DA HO:MI+ZONE\nLast-Translator: FULL NAME <EMAIL@ADDRESS>\nLanguage-Team: LANGUAGE <[email protected]>\nMIME-Version: 1.0\nContent-Type: text/plain; charset=UTF-8\nContent-Transfer-Encoding: 8bit\n"
55
],
66
[
77
"\n newlines \n",
1 Byte
Binary file not shown.

Tools/i18n/msgfmt.py

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -161,10 +161,12 @@ def make(filename, outfile):
161161
if not msgid:
162162
# Filter out POT-Creation-Date
163163
# See issue #131852
164-
msgstr = "\n".join(
165-
line
166-
for line in msgstr.decode(encoding).splitlines()
167-
if not line.startswith("POT-Creation-Date:")
164+
import re
165+
msgstr = re.sub(
166+
r"^POT-Creation-Date:.*(?:\n|$)",
167+
"",
168+
msgstr.decode(encoding),
169+
flags=re.MULTILINE,
168170
).encode(encoding)
169171

170172
# See whether there is an encoding declaration

0 commit comments

Comments
 (0)