Repository navigation
Restore LC_NUMERIC when a localized format raises - #2474
Merged
andrewgsavage merged 2 commits intoOct 11, 2026
Merged
Conversation
override_locale restored LC_NUMERIC only after the yield, so an exception in the wrapped formatting call skipped the restore and left the process-wide locale changed. Save the previous setting with setlocale(LC_NUMERIC) rather than getlocale(): the returned name round-trips on platforms where the (language, encoding) pair is rejected, and restore it in a finally block so both the raising and successful paths clean up.
Merging this PR will not alter performance
|
barlowa124
added a commit
to barlowa124/barlowa124
that referenced
this pull request
Oct 20, 2026
…un oncology ledger - Record newly merged upstream PRs: rdkit#9670, rdkit#9674, openmm#5487, deeptools/pyBigWig#167, sgkit-dev/sgkit#1353, hgrecco/pint#2474, and openmc-dev/openmc#4188 - Add ailm-inspectable to the Trustworthy ML and scientific agents table - Update oncology-coscientist summary with the 68-run ledger and 2x3 Qwen2.5-3B/14B sweep - Add .gitignore for local untracked notes Generated with [Devin](https://devin.ai) Co-Authored-By: Devin <158243242+devin-ai-integration[bot]@users.noreply.github.com>
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.
override_localerestoredLC_NUMERICon the line after itsyield, so an exception in the wrapped formatting call skipped the restore and left the process-wide locale changed. The restore is now in afinallyblock, so both the raising and successful paths clean up.The saved setting also switched from
getlocale()to a baresetlocale(LC_NUMERIC)call, which returns the current locale name in the formsetlocaleaccepts back.getlocale()returns a(language, encoding)pair thatsetlocalerejects on Windows, so even the successful path could fail to restore.A new test in
test_babel.pyasserts the locale survives both aValueErrorinside the formatter call and a successful localized format. It needs ade_DElocale and skips where one is unavailable.pre-commit run --all-filesorpixi run lint --all-fileswith no errors