Skip to content

gh-91992: Fall back to UTF-8 if an unsupported locale is provided#139429

Closed
StanFromIreland wants to merge 4 commits into
python:mainfrom
StanFromIreland:unsup-locale-crasher
Closed

gh-91992: Fall back to UTF-8 if an unsupported locale is provided#139429
StanFromIreland wants to merge 4 commits into
python:mainfrom
StanFromIreland:unsup-locale-crasher

Conversation

@StanFromIreland

@StanFromIreland StanFromIreland commented Sep 29, 2025

Copy link
Copy Markdown
Member

Note that on main UTF-8 mode is now default so this is only an issue if disabled.

text=True)
self.assertEqual(cmd.stdout.rstrip(), loc)

def test_unsupported_locale_fallback_to_utf8(self):

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'm not quite sure where to put this test.

@methane

methane commented Sep 30, 2025

Copy link
Copy Markdown
Member

I'm not sure it's a good idea to automatically modify the stdio encoding. If the locale encoding isn't available, how much likelihood is there that the application will function properly after Python starts? Wouldn't it be better to also produce an error if the user has set an incorrect PYTHONIOENCODING?

@serhiy-storchaka

Copy link
Copy Markdown
Member

If the user disabled UTF-8 mode, I think that it is incorrect to ignore this. Error is more preferable to producing mojibake.

@StanFromIreland

Copy link
Copy Markdown
Member Author

Ok, so I propose throwing a more informative error then.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants