Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix the way obsolete messages are stored #1132

Merged
merged 2 commits into from
Oct 20, 2024
Merged

Conversation

tomasr8
Copy link
Member

@tomasr8 tomasr8 commented Sep 23, 2024

Closes #1124

Previously, the Catalog.obsolete dictionary would use the msgid as a key to store messages.
When there are two messages with the same id but a different context, the latter one overwrites the former.

The fix is to use Catalog._get_key as the key, same as for _messages.

This might be considered a breaking change, however the only documentation for Catalog.obsolete is this:
image

The docs never say anything about how the keys are computed, so I think it should be safe to make this change (and perhaps document it too?)

Copy link

codecov bot commented Sep 23, 2024

Codecov Report

All modified and coverable lines are covered by tests ✅

Project coverage is 91.31%. Comparing base (f91754b) to head (efea1fe).
Report is 8 commits behind head on master.

Additional details and impacted files
@@            Coverage Diff             @@
##           master    #1132      +/-   ##
==========================================
+ Coverage   91.26%   91.31%   +0.05%     
==========================================
  Files          27       27              
  Lines        4602     4618      +16     
==========================================
+ Hits         4200     4217      +17     
+ Misses        402      401       -1     
Flag Coverage Δ
macos-12-3.10 90.08% <100.00%> (+0.01%) ⬆️
macos-12-3.11 90.01% <100.00%> (+0.01%) ⬆️
macos-12-3.12 90.23% <100.00%> (+0.05%) ⬆️
macos-12-3.13-dev 89.75% <100.00%> (+0.05%) ⬆️
macos-12-3.8 90.01% <100.00%> (+0.01%) ⬆️
macos-12-3.9 90.01% <100.00%> (+0.01%) ⬆️
macos-12-pypy3.10 90.08% <100.00%> (+0.01%) ⬆️
ubuntu-22.04-3.10 90.10% <100.00%> (+0.01%) ⬆️
ubuntu-22.04-3.11 90.03% <100.00%> (+0.01%) ⬆️
ubuntu-22.04-3.12 90.25% <100.00%> (+0.05%) ⬆️
ubuntu-22.04-3.13-dev 89.77% <100.00%> (+0.05%) ⬆️
ubuntu-22.04-3.8 90.03% <100.00%> (+0.01%) ⬆️
ubuntu-22.04-3.9 90.03% <100.00%> (+0.01%) ⬆️
ubuntu-22.04-pypy3.10 90.10% <100.00%> (+0.01%) ⬆️
windows-2022-3.10 90.22% <100.00%> (+0.01%) ⬆️
windows-2022-3.11 90.15% <100.00%> (+0.01%) ⬆️
windows-2022-3.12 90.37% <100.00%> (+0.05%) ⬆️
windows-2022-3.13-dev 89.89% <100.00%> (+0.05%) ⬆️
windows-2022-3.8 90.15% <100.00%> (+0.01%) ⬆️
windows-2022-3.9 90.15% <100.00%> (+0.01%) ⬆️
windows-2022-pypy3.10 90.22% <100.00%> (+0.01%) ⬆️

Flags with carried forward coverage won't be shown. Click here to find out more.

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

Copy link
Member

@akx akx left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I don't think we need to document this as a breaking change, but let's check that we would still do the right thing when serializing a catalog after this change? (See comment within.)

assert message.context == 'other'
assert message.string == 'Voh'

def test_obsolete_messages_with_context(self):
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Could we add a roundtrip test here – write_po(ignore_obsolete=False)/generate_po(ignore_obsolete=False) reads .obsolete, so we should maybe see that we get the same stuff back out?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Added!

@akx akx added this to the Babel 2.17 milestone Oct 19, 2024
Copy link
Member

@akx akx left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

📜 👍

@akx akx merged commit 313277a into python-babel:master Oct 20, 2024
26 checks passed
@tomasr8 tomasr8 deleted the obsolete branch October 20, 2024 11:32
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.

Obsoletes with same ID from different contexts get removed on update
2 participants