Skip to content

fix: remove hardcoded ioLocale from SavWriter to fix locale error#3034

Merged
FrankApiyo merged 2 commits intomainfrom
ONADATA-991
Mar 25, 2026
Merged

fix: remove hardcoded ioLocale from SavWriter to fix locale error#3034
FrankApiyo merged 2 commits intomainfrom
ONADATA-991

Conversation

@FrankApiyo
Copy link
Copy Markdown
Member

Summary

  • Remove the hardcoded ioLocale=str("en_US.UTF-8") parameter from the SavWriter call in to_zipped_sav, fixing SAV exports on containers that lack the en_US.UTF-8 locale.

Why ioLocale was a no-op

SavWriter accepts two encoding-related parameters:

Parameter What it does
ioUtf8=True Tells the SPSS I/O library to encode all string data (variable names, labels, values) as UTF-8 inside the .sav file. This is what controls the file encoding.
ioLocale Calls locale.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. So ioLocale="en_US.UTF-8" had no effect on the actual .sav output — ioUtf8=True (already set via _get_sav_options()) was doing all the work.

Removing ioLocale lets SavWriter fall back to locale.setlocale(LC_ALL, "") (the system default), which always succeeds regardless of which locales are installed.

This change does not break anything

  • The SPSS file content is identical — ioUtf8=True remains in place and fully controls UTF-8 encoding
  • All existing SAV export tests pass without modification, confirming no behavioral change
  • The only difference is that the export no longer crashes on containers missing en_US.UTF-8

Test plan

  • Verify SAV/SPSS zip export succeeds on staging (previously failing)
  • Verify exported .sav file opens correctly in SPSS and contains expected UTF-8 data
  • Run existing test_export_builder.py SAV tests

Fixes #3033 / ONADATA-991

@linear
Copy link
Copy Markdown

linear bot commented Mar 23, 2026

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
@FrankApiyo FrankApiyo merged commit 4dfa567 into main Mar 25, 2026
11 of 12 checks passed
@FrankApiyo FrankApiyo deleted the ONADATA-991 branch March 25, 2026 06:55
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Error: unsupported locale setting

2 participants