Reconfigure the text stream with new parameters. This also flushes the stream.
(self, *,
encoding=None, errors=None, newline=Ellipsis,
line_buffering=None, write_through=None)
| 2130 | return self._buffer |
| 2131 | |
| 2132 | def reconfigure(self, *, |
| 2133 | encoding=None, errors=None, newline=Ellipsis, |
| 2134 | line_buffering=None, write_through=None): |
| 2135 | """Reconfigure the text stream with new parameters. |
| 2136 | |
| 2137 | This also flushes the stream. |
| 2138 | """ |
| 2139 | if (self._decoder is not None |
| 2140 | and (encoding is not None or errors is not None |
| 2141 | or newline is not Ellipsis)): |
| 2142 | raise UnsupportedOperation( |
| 2143 | "It is not possible to set the encoding or newline of stream " |
| 2144 | "after the first read") |
| 2145 | |
| 2146 | if errors is None: |
| 2147 | if encoding is None: |
| 2148 | errors = self._errors |
| 2149 | else: |
| 2150 | errors = 'strict' |
| 2151 | elif not isinstance(errors, str): |
| 2152 | raise TypeError("invalid errors: %r" % errors) |
| 2153 | |
| 2154 | if encoding is None: |
| 2155 | encoding = self._encoding |
| 2156 | else: |
| 2157 | if not isinstance(encoding, str): |
| 2158 | raise TypeError("invalid encoding: %r" % encoding) |
| 2159 | if encoding == "locale": |
| 2160 | encoding = self._get_locale_encoding() |
| 2161 | |
| 2162 | if newline is Ellipsis: |
| 2163 | newline = self._readnl |
| 2164 | self._check_newline(newline) |
| 2165 | |
| 2166 | if line_buffering is None: |
| 2167 | line_buffering = self.line_buffering |
| 2168 | if write_through is None: |
| 2169 | write_through = self.write_through |
| 2170 | |
| 2171 | self.flush() |
| 2172 | self._configure(encoding, errors, newline, |
| 2173 | line_buffering, write_through) |
| 2174 | |
| 2175 | def seekable(self): |
| 2176 | if self.closed: |
nothing calls this directly
no test coverage detected