Reset locale to "C" after charset test #39648
Merged
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.
Summary
SUMMARY: none
Purpose of change
The
catacharset_test
includes a call tosetlocale( LC_ALL, "" )
, which uses the locale from the current environment (which may or may not be English).Suspect this as a possible cause of #39423, where other test cases are failing due to the use of locale-specific numerical formatting (like "." vs "," for the decimal separator).
Describe the solution
Explicitly setting locale back to "C" after these tests should avoid the problem, because this "is a rather neutral locale with minimal locale information that allows the result of programs to be predictable." setlocale
Describe alternatives you've considered
None
Testing
I tried and failed to reproduce the original issue by modifying my own system locale (and I hesitated to dive deeper due to my own flimsy grasp of non-English languages). So I cannot say whether this change will fix the bug, but I made sure
tests/cata_test [catacharset],[tname]
andtests/cata_test [catacharset],string_formatter
are still passing on my own Ubuntu box with English/US locale.Even if it doesn't fix the bug, I think it's a worthwhile post-test cleanup.
Additional context
Credit to @jbytheway