@@ -1868,17 +1868,16 @@ mod _io {
18681868
18691869 #[ derive( FromArgs ) ]
18701870 struct TextIOWrapperArgs {
1871- buffer : PyObjectRef ,
18721871 #[ pyarg( any, default ) ]
18731872 encoding : Option < PyStrRef > ,
18741873 #[ pyarg( any, default ) ]
18751874 errors : Option < PyStrRef > ,
18761875 #[ pyarg( any, default ) ]
1877- newline : Newlines ,
1878- #[ pyarg( any, default = "false" ) ]
1879- line_buffering : bool ,
1880- #[ pyarg( any, default = "false" ) ]
1881- write_through : bool ,
1876+ newline : Option < Newlines > ,
1877+ #[ pyarg( any, default ) ]
1878+ line_buffering : Option < bool > ,
1879+ #[ pyarg( any, default ) ]
1880+ write_through : Option < bool > ,
18821881 }
18831882
18841883 #[ derive( Debug , Copy , Clone , Default ) ]
@@ -2196,9 +2195,13 @@ mod _io {
21962195 impl DefaultConstructor for TextIOWrapper { }
21972196
21982197 impl Initializer for TextIOWrapper {
2199- type Args = TextIOWrapperArgs ;
2198+ type Args = ( PyObjectRef , TextIOWrapperArgs ) ;
22002199
2201- fn init ( zelf : PyRef < Self > , args : Self :: Args , vm : & VirtualMachine ) -> PyResult < ( ) > {
2200+ fn init (
2201+ zelf : PyRef < Self > ,
2202+ ( buffer, args) : Self :: Args ,
2203+ vm : & VirtualMachine ,
2204+ ) -> PyResult < ( ) > {
22022205 let mut data = zelf. lock_opt ( vm) ?;
22032206 * data = None ;
22042207
@@ -2218,8 +2221,6 @@ mod _io {
22182221 . errors
22192222 . unwrap_or_else ( || PyStr :: from ( "strict" ) . into_ref ( & vm. ctx ) ) ;
22202223
2221- let buffer = args. buffer ;
2222-
22232224 let has_read1 = vm. get_attribute_opt ( buffer. clone ( ) , "read1" ) ?. is_some ( ) ;
22242225 let seekable = vm. call_method ( & buffer, "seekable" , ( ) ) ?. try_to_bool ( vm) ?;
22252226
@@ -2256,9 +2257,9 @@ mod _io {
22562257 decoder,
22572258 encoding,
22582259 errors,
2259- newline : args. newline ,
2260- line_buffering : args. line_buffering ,
2261- write_through : args. write_through ,
2260+ newline : args. newline . unwrap_or_default ( ) ,
2261+ line_buffering : args. line_buffering . unwrap_or_default ( ) ,
2262+ write_through : args. write_through . unwrap_or_default ( ) ,
22622263 chunk_size : 8192 ,
22632264 seekable,
22642265 has_read1,
@@ -2294,6 +2295,27 @@ mod _io {
22942295
22952296 #[ pyclass( with( Constructor , Initializer ) , flags( BASETYPE ) ) ]
22962297 impl TextIOWrapper {
2298+ #[ pymethod]
2299+ fn reconfigure ( & self , args : TextIOWrapperArgs ) {
2300+ let mut data = self . data . lock ( ) . unwrap ( ) ;
2301+ if let Some ( data) = data. as_mut ( ) {
2302+ if let Some ( encoding) = args. encoding {
2303+ data. encoding = encoding;
2304+ }
2305+ if let Some ( errors) = args. errors {
2306+ data. errors = errors;
2307+ }
2308+ if let Some ( newline) = args. newline {
2309+ data. newline = newline;
2310+ }
2311+ if let Some ( line_buffering) = args. line_buffering {
2312+ data. line_buffering = line_buffering;
2313+ }
2314+ if let Some ( write_through) = args. write_through {
2315+ data. write_through = write_through;
2316+ }
2317+ }
2318+ }
22972319 #[ pymethod]
22982320 fn seekable ( & self , vm : & VirtualMachine ) -> PyResult {
22992321 let textio = self . lock ( vm) ?;
0 commit comments