@@ -1951,6 +1951,7 @@ public class TextIOWrapper : _TextIOBase, IEnumerator<object>, IEnumerable<objec
19511951 private object _encoder , _decoder ;
19521952
19531953 private bool _line_buffering ;
1954+ private bool _write_through ;
19541955 private bool _readUniversal ;
19551956 private bool _readTranslate ;
19561957 internal bool _writeTranslate ;
@@ -1969,12 +1970,12 @@ public TextIOWrapper(CodeContext/*!*/ context) : base(context) { }
19691970
19701971 internal static TextIOWrapper Create ( CodeContext /*!*/ context ,
19711972 object buffer ,
1972- string encoding = null ,
1973- string errors = null ,
1974- string newline = null ,
1975- bool line_buffering = false ) {
1973+ string encoding = null ,
1974+ string errors = null ,
1975+ string newline = null ,
1976+ bool line_buffering = false , bool write_through = false ) {
19761977 var res = new TextIOWrapper ( context ) ;
1977- res . __init__ ( context , buffer , encoding , errors , newline , line_buffering ) ;
1978+ res . __init__ ( context , buffer , encoding , errors , newline , line_buffering , write_through ) ;
19781979 return res ;
19791980 }
19801981
@@ -1983,8 +1984,9 @@ public void __init__(
19831984 object buffer ,
19841985 string encoding = null ,
19851986 string errors = null ,
1986- string newline = null ,
1987- bool line_buffering = false
1987+ string newline = null ,
1988+ bool line_buffering = false ,
1989+ bool write_through = false
19881990 ) {
19891991 switch ( newline ) {
19901992 case null :
@@ -2017,6 +2019,7 @@ public void __init__(
20172019 PythonOps . IsTrue ( PythonOps . Invoke ( context , _buffer , "seekable" ) ) ;
20182020
20192021 _line_buffering = line_buffering ;
2022+ _write_through = write_through ;
20202023 _readUniversal = string . IsNullOrEmpty ( newline ) ;
20212024 _readTranslate = newline == null ;
20222025 _readNL = newline ;
@@ -2029,23 +2032,15 @@ public void __init__(
20292032
20302033 #region Public API
20312034
2032- public object buffer {
2033- get {
2034- return _buffer ;
2035- }
2036- }
2035+ public object buffer => _buffer ;
20372036
2038- public override string encoding {
2039- get { return _encoding ; }
2040- }
2037+ public override string encoding => _encoding ;
20412038
2042- public override string errors {
2043- get { return _errors ; }
2044- }
2039+ public override string errors => _errors ;
20452040
2046- public bool line_buffering {
2047- get { return _line_buffering ; }
2048- }
2041+ public bool line_buffering => _line_buffering ;
2042+
2043+ public bool write_through => _write_through ;
20492044
20502045 public override object newlines {
20512046 get {
@@ -2157,7 +2152,7 @@ public override BigInteger write(CodeContext/*!*/ context, object s) {
21572152 PythonOps . Invoke ( context , _buffer , "write" , bytes ) ;
21582153 }
21592154
2160- if ( _line_buffering && ( hasLF || str . Contains ( "\r " ) ) ) {
2155+ if ( _write_through || _line_buffering && ( hasLF || str . Contains ( "\r " ) ) ) {
21612156 flush ( context ) ;
21622157 }
21632158
0 commit comments