Skip to content

Fix Catalog.is_identical() for messages with msgctxt - #1329

Open
abhijeet117 wants to merge 1 commit into
python-babel:masterfrom
abhijeet117:fix/is-identical-msgctxt
Open

Fix Catalog.is_identical() for messages with msgctxt#1329
abhijeet117 wants to merge 1 commit into
python-babel:masterfrom
abhijeet117:fix/is-identical-msgctxt

Conversation

@abhijeet117

Copy link
Copy Markdown

Summary

Catalog.is_identical() returned False for any catalog containing a context-specific message, even when compared with itself, so pybabel update --check reported such catalogs as out of date on every run. The internal (msgid, msgctxt) keys were resolved through get(), which strips the context and looks the message up by msgid only. The lookup now uses the internal keys directly.

Testing

Reproduced on master: a catalog with one pgettext-style message returned False from is_identical(cat). Added catalog tests covering self-comparison, equal catalogs, differing context, differing string and context-free cases; the context test fails without the fix. Full suite: 7828 passed with only two pre-existing timezone-name failures identical on a clean tree.

Checklist

  • Bug reproduced before the fix
  • Root cause identified
  • Bug fixed
  • Tests passed

is_identical() iterated the internal _messages keys, which for
context-specific messages are (msgid, msgctxt) tuples, but resolved them
through get(), whose _key_for() collapses a tuple id to just the msgid.
The lookup therefore always missed context-specific messages and the
method returned False, making pybabel update --check report any catalog
containing a msgctxt as out of date on every run.

Look up the internal keys directly instead of round-tripping through
get().
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant