Fix standalone month alias cache leakage#1263
Open
BlocksecPHD wants to merge 1 commit intopython-babel:masterfrom
Open
Fix standalone month alias cache leakage#1263BlocksecPHD wants to merge 1 commit intopython-babel:masterfrom
BlocksecPHD wants to merge 1 commit intopython-babel:masterfrom
Conversation
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Problem background
Using
babel.dates.format_date(..., 'LLLL', locale='he')could corrupt later standalone month-name lookups for other locales in the same process. After Hebrew resolvedmonths['stand-alone']['wide'], subsequentLLLLformatting for locales such asno,fr, anddecould incorrectly return Hebrew month names.The underlying issue was in
LocaleDataDict.__getitem__(): when an alias resolved to a nested dict, the resolvedLocaleDataDictwrapper was memoized back into the underlying cached locale data. That leaked alias resolution state across locales through the shared locale-data cache.Changes summary
LocaleDataDict.__getitem__().LLLLformatting after Hebrew forde,no, andfr, while preserving the expected Hebrew result itself.Test results
v2.16.0with:de -> Oktoberhe -> אוקטוברno -> אוקטובר(wrong before fix)fr -> אוקטובר(wrong before fix)master:de -> Oktoberhe -> אוקטוברno -> oktoberfr -> octobrepytest tests/test_dates.py -k 'standalone_month_name_isolation or test_format_date' -qpytest tests/test_localedata.py tests/test_core.py tests/test_dates.py -q3441 passed, 1 skipped, 2 xfailedRisk assessment
Low risk. The change is narrowly scoped to avoid caching
LocaleDataDictwrappers for nested dict values. Non-dict scalar alias resolutions are still memoized as before, and the added regression test specifically covers the cross-locale contamination case.