fix(localedata): don't memoize resolved aliases into shared parent data#1274
Open
SAY-5 wants to merge 1 commit into
Open
fix(localedata): don't memoize resolved aliases into shared parent data#1274SAY-5 wants to merge 1 commit into
SAY-5 wants to merge 1 commit into
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.
Fixes #1234.
A locale that inherits an entire nested sub-dict from its parent shares the same dict object (merge only copies keys present in the child's own data). When
LocaleDataDict.__getitem__resolved anAliasand wrote the resolved value back intoself._dataas a memoization, it mutated that shared dict, corrupting the parent locale (and every sibling that inherits it).For example
healiases its stand-alone wide months to the Hebrew format months. Afterformat_date(d, 'LLLL', 'he'), a laterformat_date(d, 'LLLL', 'de')returned Hebrew text because root's sharedmonths/stand-alone/wideAlias had been overwritten.Fix: skip the write-back memoization when the value came from resolving an alias, since the backing dict may be shared with a parent locale. Plain nested dicts are still wrapped and memoized as before.
Added a regression test.