Skip to content

Conversation

@MegasKomnenos
Copy link
Contributor

@MegasKomnenos MegasKomnenos commented Mar 26, 2023

fix #4662

@MegasKomnenos MegasKomnenos changed the title Add encoding='locale' Add encoding="locale" support for TextIOWrapper Mar 26, 2023
Copy link
Member

@youknowone youknowone left a comment

Choose a reason for hiding this comment

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

And you fixed 2 more tests by this change!

UNEXPECTED SUCCESS: test__getitem___deprecation (test.test_fileinput.FileInputTests.test__getitem___deprecation)
UNEXPECTED SUCCESS: test_gz_ext_fake (test.test_fileinput.Test_hook_compressed.test_gz_ext_fake)

Please remove unittest.expectedFailure from those tests

Copy link
Member

@youknowone youknowone left a comment

Choose a reason for hiding this comment

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

Thank you for contributing!

I also changed the type from u8 to bool. No difference functionality-wise.
None => {
// TODO: try os.device_encoding(fileno) and then locale.getpreferredencoding()
PyStr::from(crate::codecs::DEFAULT_ENCODING).into_ref(&vm.ctx)
None if vm.state.settings.utf8_mode == 1 => PyStr::from("utf-8").into_ref(&vm.ctx),
Copy link
Member

Choose a reason for hiding this comment

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

Suggested change
None if vm.state.settings.utf8_mode == 1 => PyStr::from("utf-8").into_ref(&vm.ctx),
None if vm.state.settings.utf8_mode > 0 => PyStr::from("utf-8").into_ref(&vm.ctx),

@youknowone youknowone added this pull request to the merge queue Mar 28, 2023
Merged via the queue into RustPython:main with commit 1a7df66 Mar 28, 2023
@youknowone youknowone added C-compat A discrepancy between RustPython and CPython A-stdlib z-ca-2023 Tag to track contrubution-academy 2023 labels Mar 28, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

A-stdlib C-compat A discrepancy between RustPython and CPython z-ca-2023 Tag to track contrubution-academy 2023

Projects

None yet

Development

Successfully merging this pull request may close these issues.

io.TextIOWrapper.__init__ encoding="locale" support

2 participants