File tree Expand file tree Collapse file tree 4 files changed +12
-9
lines changed Expand file tree Collapse file tree 4 files changed +12
-9
lines changed Original file line number Diff line number Diff line change @@ -391,8 +391,6 @@ def test__getitem__(self):
391
391
retval2 = fi [1 ]
392
392
self .assertEqual (retval2 , "line2\n " )
393
393
394
- # TODO: RUSTPYTHON
395
- @unittest .expectedFailure
396
394
def test__getitem___deprecation (self ):
397
395
t = self .writeTmp ("line1\n line2\n " )
398
396
with self .assertWarnsRegex (DeprecationWarning ,
@@ -914,8 +912,6 @@ def test_empty_string(self):
914
912
def test_no_ext (self ):
915
913
self .do_test_use_builtin_open ("abcd" , 2 )
916
914
917
- # TODO: RUSTPYTHON
918
- @unittest .expectedFailure
919
915
@unittest .skipUnless (gzip , "Requires gzip and zlib" )
920
916
def test_gz_ext_fake (self ):
921
917
original_open = gzip .open
Original file line number Diff line number Diff line change @@ -2193,10 +2193,14 @@ mod _io {
2193
2193
* data = None ;
2194
2194
2195
2195
let encoding = match args. encoding {
2196
- Some ( enc) => enc,
2197
- None => {
2198
- // TODO: try os.device_encoding(fileno) and then locale.getpreferredencoding()
2199
- PyStr :: from ( crate :: codecs:: DEFAULT_ENCODING ) . into_ref ( & vm. ctx )
2196
+ None if vm. state . settings . utf8_mode > 0 => PyStr :: from ( "utf-8" ) . into_ref ( & vm. ctx ) ,
2197
+ Some ( enc) if enc. as_str ( ) != "locale" => enc,
2198
+ _ => {
2199
+ // None without utf8_mode or "locale" encoding
2200
+ vm. import ( "locale" , None , 0 ) ?
2201
+ . get_attr ( "getencoding" , vm) ?
2202
+ . call ( ( ) , vm) ?
2203
+ . try_into_value ( vm) ?
2200
2204
}
2201
2205
} ;
2202
2206
Original file line number Diff line number Diff line change @@ -728,7 +728,7 @@ mod sys {
728
728
hash_randomization : settings. hash_seed . is_none ( ) as u8 ,
729
729
isolated : settings. isolated as u8 ,
730
730
dev_mode : settings. dev_mode ,
731
- utf8_mode : 1 ,
731
+ utf8_mode : settings . utf8_mode ,
732
732
int_max_str_digits : -1 ,
733
733
safe_path : false ,
734
734
warn_default_encoding : settings. warn_default_encoding as u8 ,
Original file line number Diff line number Diff line change @@ -74,6 +74,8 @@ pub struct Settings {
74
74
/// false for wasm. Not a command-line option
75
75
pub allow_external_library : bool ,
76
76
77
+ pub utf8_mode : u8 ,
78
+
77
79
#[ cfg( feature = "flame-it" ) ]
78
80
pub profile_output : Option < OsString > ,
79
81
#[ cfg( feature = "flame-it" ) ]
@@ -107,6 +109,7 @@ impl Default for Settings {
107
109
stdio_unbuffered : false ,
108
110
check_hash_based_pycs : "default" . to_owned ( ) ,
109
111
allow_external_library : cfg ! ( feature = "importlib" ) ,
112
+ utf8_mode : 1 ,
110
113
#[ cfg( feature = "flame-it" ) ]
111
114
profile_output : None ,
112
115
#[ cfg( feature = "flame-it" ) ]
You can’t perform that action at this time.
0 commit comments