This issue tracker has been migrated to GitHub, and is currently read-only.
For more information, see the GitHub FAQs in the Python's Developer Guide.

classification
Title: Incorrect handling for msgctxt in msgfmt.py
Type: behavior Stage:
Components: Demos and Tools Versions: Python 3.8
process
Status: open Resolution:
Dependencies: Superseder:
Assigned To: Nosy List: da1910
Priority: normal Keywords: patch

Created on 2020-05-31 20:56 by da1910, last changed 2022-04-11 14:59 by admin.

Files
File name Uploaded Description Edit
test.po da1910, 2020-05-31 20:58
40835.patch da1910, 2020-05-31 21:16
Messages (3)
msg370502 - (view) Author: Doug Addy (da1910) * Date: 2020-05-31 20:56
Running msgfmt.py with the attached po file will produce an incorrect context for the entry "test".

Looking at the script, we require a comment to follow a contexted section for the context to be cleared. The gettext documentation makes clear that all comments are optional, so this is not desired behaviour.

My reading of the gettext documentation has a "msgctxt" line applying only to the current entry, so it should be cleared once the last msgstr has been written for that entry.

I will endeavour to provide a patch within the next day or two.
msg370504 - (view) Author: Doug Addy (da1910) * Date: 2020-05-31 20:58
Test po file included
msg370507 - (view) Author: Doug Addy (da1910) * Date: 2020-05-31 21:16
And a patch:

After the end of a message entry the options for the next line are:
1. A comment - we already reset msgctxt to None here
2. A blank line - we can have empty lines anywhere we want, so do nothing
3. A new msgctxt line - Set msgctxt to the new context
4. A msgid - This is the current failing behaviour. Fix sets msgctxt back to None.
History
Date User Action Args
2022-04-11 14:59:31adminsetgithub: 85012
2020-05-31 21:16:05da1910setfiles: + 40835.patch
keywords: + patch
messages: + msg370507
2020-05-31 20:58:35da1910setfiles: + test.po

messages: + msg370504
2020-05-31 20:56:52da1910create