MCPcopy Index your code
hub / github.com/python/cpython / reconfigure

Method reconfigure

Lib/_pyio.py:2191–2232  ·  view source on GitHub ↗

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)

Source from the content-addressed store, hash-verified

2189 return self._buffer
2190
2191 def reconfigure(self, *,
2192 encoding=None, errors=None, newline=Ellipsis,
2193 line_buffering=None, write_through=None):
2194 """Reconfigure the text stream with new parameters.
2195
2196 This also flushes the stream.
2197 """
2198 if (self._decoder is not None
2199 and (encoding is not None or errors is not None
2200 or newline is not Ellipsis)):
2201 raise UnsupportedOperation(
2202 "It is not possible to set the encoding or newline of stream "
2203 "after the first read")
2204
2205 if errors is None:
2206 if encoding is None:
2207 errors = self._errors
2208 else:
2209 errors = 'strict'
2210 elif not isinstance(errors, str):
2211 raise TypeError("invalid errors: %r" % errors)
2212
2213 if encoding is None:
2214 encoding = self._encoding
2215 else:
2216 if not isinstance(encoding, str):
2217 raise TypeError("invalid encoding: %r" % encoding)
2218 if encoding == "locale":
2219 encoding = self._get_locale_encoding()
2220
2221 if newline is Ellipsis:
2222 newline = self._readnl
2223 self._check_newline(newline)
2224
2225 if line_buffering is None:
2226 line_buffering = self.line_buffering
2227 if write_through is None:
2228 write_through = self.write_through
2229
2230 self.flush()
2231 self._configure(encoding, errors, newline,
2232 line_buffering, write_through)
2233
2234 def seekable(self):
2235 if self.closed:

Calls 5

_get_locale_encodingMethod · 0.95
_check_newlineMethod · 0.95
flushMethod · 0.95
_configureMethod · 0.95