Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

bootloader: set configure_locale=1 in interpreter pre-config #8306

Merged
merged 3 commits into from Feb 17, 2024

Conversation

rokm
Copy link
Member

@rokm rokm commented Feb 17, 2024

Have bootloader set the configure_locale field in the interpreter pre-config structure, so that user-preferred locale is set during interpreter pre-initialization.

This fixes regression w.r.t. PyInstaller 5.x and unfrozen python, where calling locale.getlocale in frozen application returns user-preferred locale, while frozen applications created by PyInstaller 6.x currently return (None, None). By extension, this fixes #8305.

In PyInstaller 5.x bootloader, user-preferred locale was set explicitly by bootloader calling setlocale in C code; now, we can let python interpreter (pre)initialization handle that for us.

@rokm
Copy link
Member Author

rokm commented Feb 17, 2024

Hmm, looks like the CI runner does not come with the extra locales. Should we adjust the workflow to install/enable them, or can we live without that part of the test?

@bwoodsend
Copy link
Member

I see you've already done it but yeah, I think installing the locales on CI sounds sensible.

Have bootloader set the `configure_locale` field in the interpreter
pre-config structure, so that user-preferred locale is set during
interpreter pre-initialization.

This fixes regression w.r.t. PyInstaller 5.x and unfrozen python,
where calling `locale.getlocale` in frozen application returns
user-preferred locale, while frozen applications created by
PyInstaller 6.x currently return `(None, None)`.

In PyInstaller 5.x bootloader, user-preferred locale was set
explicitly by bootloader calling `setlocale` in C code; now,
we can let python interpreter (pre)initialization handle that
for us.
Add a test that ensures that user-preferred locale is set on the
POSIX systems; i.e., that `locale.getlocale()` does not return
`(None, None)` and that values in the tuple correspond to
locale/encoding set via environment variable (`LC_ALL`).
The ubuntu CI runner does not come with any locales enabled, so
we need to explicitly enable the following locales for
`test_basic::test_user_preferred_locale`:
 - en_US.UTF-8
 - en_US (= en_US.ISO8859-1)
 - sl_SI.UTF-8
 - sl_SI (= sl_SI.ISO8859-2)

In addition, `test_basic::test_time_module_localized` seems to
be using `cs_CZ.UTF-8`, so enable that as well.
@rokm rokm merged commit 4cc30d0 into pyinstaller:develop Feb 17, 2024
2 of 18 checks passed
@rokm rokm deleted the fix-user-preferred-locale branch February 17, 2024 22:06
@github-actions github-actions bot locked as resolved and limited conversation to collaborators Apr 18, 2024
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Program crashes when using the newest pyinstaller
2 participants