Closed LeXofLeviafan closed 1 month ago
Seems to be an issue with how the obsolete mesages are parsed:
The above looks to only be using the msgid, rather than (msgid, msgctx)
, so messages with the same msgid but different msgctx will get overwritten. This seems to fix it:
if self.obsolete:
if not self.ignore_obsolete:
- self.catalog.obsolete[msgid] = message
+ self.catalog.obsolete[self.catalog._key_for(msgid, msgctxt)] = message
Overview Description
When a file contains multiple obsoletes from different contexts, and they have the same ID, all but the last one will get stripped from the file.
Steps to Reproduce
Place multiple messages into a PO file with same
msgid
but differentmsgctxt
(in arbitrary order, optionally including one without amsgctxt
as well):Run
pybabel update
with appropriate params; the messages should be moved to the end of the file and marked obsolete:Actual Results
Only the last obsolete entry with that
msgid
remains in the file (based on their order before the last update command, and regardless of whether a message withoutmsgctxt
was present):Expected Results
The messages were from different contexts so they should all be retained.
Reproducibility
This issue appears to reproduce whenever the described situation occurs.
Additional Information
Tested on Babel version 2.16.0