diff options
Diffstat (limited to 'Lib/_pyio.py')
-rw-r--r-- | Lib/_pyio.py | 23 |
1 files changed, 22 insertions, 1 deletions
diff --git a/Lib/_pyio.py b/Lib/_pyio.py index 5dfc1f0..d50230d 100644 --- a/Lib/_pyio.py +++ b/Lib/_pyio.py @@ -1943,7 +1943,6 @@ class TextIOWrapper(TextIOBase): raise ValueError("invalid errors: %r" % errors) self._buffer = buffer - self._line_buffering = line_buffering self._encoding = encoding self._errors = errors self._readuniversal = not newline @@ -1969,6 +1968,12 @@ class TextIOWrapper(TextIOBase): # Sometimes the encoder doesn't exist pass + self._configure(line_buffering, write_through) + + def _configure(self, line_buffering=False, write_through=False): + self._line_buffering = line_buffering + self._write_through = write_through + # self._snapshot is either None, or a tuple (dec_flags, next_input) # where dec_flags is the second (integer) item of the decoder state # and next_input is the chunk of input bytes that comes next after the @@ -2008,9 +2013,25 @@ class TextIOWrapper(TextIOBase): return self._line_buffering @property + def write_through(self): + return self._write_through + + @property def buffer(self): return self._buffer + def reconfigure(self, *, line_buffering=None, write_through=None): + """Reconfigure the text stream with new parameters. + + This also flushes the stream. + """ + if line_buffering is None: + line_buffering = self.line_buffering + if write_through is None: + write_through = self.write_through + self.flush() + self._configure(line_buffering, write_through) + def seekable(self): if self.closed: raise ValueError("I/O operation on closed file.") |