fix: remove hardcoded ioLocale from SavWriter to fix locale error#3034
Merged
FrankApiyo merged 2 commits intomainfrom Mar 25, 2026
Merged
fix: remove hardcoded ioLocale from SavWriter to fix locale error#3034FrankApiyo merged 2 commits intomainfrom
FrankApiyo merged 2 commits intomainfrom
Conversation
The SavWriter call hardcoded ioLocale="en_US.UTF-8", which calls locale.setlocale(LC_ALL, "en_US.UTF-8") internally. This fails on containers that don't have the en_US.UTF-8 locale installed. The ioLocale parameter is unnecessary because ioUtf8=True (already set via _get_sav_options) controls UTF-8 encoding of SPSS file data. The C locale set by ioLocale only affects OS-level string collation and number display formatting, neither of which affect SPSS output since numbers are stored as IEEE 754 binary doubles. Fixes: ONADATA-991
ukanga
approved these changes
Mar 25, 2026
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.
Summary
ioLocale=str("en_US.UTF-8")parameter from theSavWritercall into_zipped_sav, fixing SAV exports on containers that lack theen_US.UTF-8locale.Why
ioLocalewas a no-opSavWriteraccepts two encoding-related parameters:ioUtf8=True.savfile. This is what controls the file encoding.ioLocalelocale.setlocale(LC_ALL, ...)to set the process-wide C locale. This affects OS-level behaviors like string collation and number display formatting.SPSS files store numbers as IEEE 754 binary doubles — they never pass through C locale number formatting. String encoding is governed entirely by
ioUtf8, not the locale. SoioLocale="en_US.UTF-8"had no effect on the actual.savoutput —ioUtf8=True(already set via_get_sav_options()) was doing all the work.Removing
ioLocaleletsSavWriterfall back tolocale.setlocale(LC_ALL, "")(the system default), which always succeeds regardless of which locales are installed.This change does not break anything
ioUtf8=Trueremains in place and fully controls UTF-8 encodingen_US.UTF-8Test plan
.savfile opens correctly in SPSS and contains expected UTF-8 datatest_export_builder.pySAV testsFixes #3033 / ONADATA-991