Skip to content
Open
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
11 changes: 1 addition & 10 deletions Lib/test/test_tools/test_msgfmt.py
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,7 @@ def test_compilation(self):
actual = GNUTranslations(f)

self.assertDictEqual(actual._catalog, expected._catalog)
self.assertFalse(msgfmt.MESSAGES)

def test_binary_header(self):
with temp_cwd():
Expand Down Expand Up @@ -145,12 +146,6 @@ def test_generic_syntax_error(self):


class POParserTest(unittest.TestCase):
@classmethod
def tearDownClass(cls):
# msgfmt uses a global variable to store messages,
# clear it after the tests.
msgfmt.MESSAGES.clear()

def test_strings(self):
# Test that the PO parser correctly handles and unescape
# strings in the PO file.
Expand Down Expand Up @@ -202,8 +197,6 @@ def test_strings(self):
# check the result.
po = f'msgid {po_string}\nmsgstr "translation"'
Path('messages.po').write_text(po)
# Reset the global MESSAGES dictionary
msgfmt.MESSAGES.clear()
msgfmt.make('messages.po', 'messages.mo')

with open('messages.mo', 'rb') as f:
Expand Down Expand Up @@ -235,8 +228,6 @@ def test_strings(self):
with self.subTest(string=invalid_string):
po = f'msgid {invalid_string}\nmsgstr "translation"'
Path('messages.po').write_text(po)
# Reset the global MESSAGES dictionary
msgfmt.MESSAGES.clear()
with self.assertRaises(Exception):
msgfmt.make('messages.po', 'messages.mo')

Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
Fix bug in :program:`msgfmt` where ``MESSAGES`` was not cleared.
3 changes: 3 additions & 0 deletions Tools/i18n/msgfmt.py
Original file line number Diff line number Diff line change
Expand Up @@ -99,6 +99,9 @@ def generate():


def make(filename, outfile):
global MESSAGES
MESSAGES.clear()

ID = 1
STR = 2
CTXT = 3
Expand Down
Loading