mirror of
https://github.com/RustPython/RustPython.git
synced 2026-06-02 19:39:49 +09:00
Add encoding='locale' support for TextIOWrapper
This commit is contained in:
committed by
Jeong YunWon
parent
e48ca2892b
commit
7e6c33152e
4
Lib/test/test_fileinput.py
vendored
4
Lib/test/test_fileinput.py
vendored
@@ -391,8 +391,6 @@ class FileInputTests(BaseTests, unittest.TestCase):
|
||||
retval2 = fi[1]
|
||||
self.assertEqual(retval2, "line2\n")
|
||||
|
||||
# TODO: RUSTPYTHON
|
||||
@unittest.expectedFailure
|
||||
def test__getitem___deprecation(self):
|
||||
t = self.writeTmp("line1\nline2\n")
|
||||
with self.assertWarnsRegex(DeprecationWarning,
|
||||
@@ -914,8 +912,6 @@ class Test_hook_compressed(unittest.TestCase):
|
||||
def test_no_ext(self):
|
||||
self.do_test_use_builtin_open("abcd", 2)
|
||||
|
||||
# TODO: RUSTPYTHON
|
||||
@unittest.expectedFailure
|
||||
@unittest.skipUnless(gzip, "Requires gzip and zlib")
|
||||
def test_gz_ext_fake(self):
|
||||
original_open = gzip.open
|
||||
|
||||
@@ -2193,10 +2193,14 @@ mod _io {
|
||||
*data = None;
|
||||
|
||||
let encoding = match args.encoding {
|
||||
Some(enc) => enc,
|
||||
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 > 0 => PyStr::from("utf-8").into_ref(&vm.ctx),
|
||||
Some(enc) if enc.as_str() != "locale" => enc,
|
||||
_ => {
|
||||
// None without utf8_mode or "locale" encoding
|
||||
vm.import("locale", None, 0)?
|
||||
.get_attr("getencoding", vm)?
|
||||
.call((), vm)?
|
||||
.try_into_value(vm)?
|
||||
}
|
||||
};
|
||||
|
||||
|
||||
Reference in New Issue
Block a user