(self, buffer, encoding=None, errors=None, newline=None,
line_buffering=False, write_through=False)
| 2018 | # implementation always writes through. The argument is present only |
| 2019 | # so that the signature can match the signature of the C version. |
| 2020 | def __init__(self, buffer, encoding=None, errors=None, newline=None, |
| 2021 | line_buffering=False, write_through=False): |
| 2022 | self._check_newline(newline) |
| 2023 | encoding = text_encoding(encoding) |
| 2024 | |
| 2025 | if encoding == "locale": |
| 2026 | encoding = self._get_locale_encoding() |
| 2027 | |
| 2028 | if not isinstance(encoding, str): |
| 2029 | raise ValueError("invalid encoding: %r" % encoding) |
| 2030 | |
| 2031 | if not codecs.lookup(encoding)._is_text_encoding: |
| 2032 | msg = ("%r is not a text encoding; " |
| 2033 | "use codecs.open() to handle arbitrary codecs") |
| 2034 | raise LookupError(msg % encoding) |
| 2035 | |
| 2036 | if errors is None: |
| 2037 | errors = "strict" |
| 2038 | else: |
| 2039 | if not isinstance(errors, str): |
| 2040 | raise ValueError("invalid errors: %r" % errors) |
| 2041 | if _CHECK_ERRORS: |
| 2042 | codecs.lookup_error(errors) |
| 2043 | |
| 2044 | self._buffer = buffer |
| 2045 | self._decoded_chars = '' # buffer for text returned from decoder |
| 2046 | self._decoded_chars_used = 0 # offset into _decoded_chars for read() |
| 2047 | self._snapshot = None # info for reconstructing decoder state |
| 2048 | self._seekable = self._telling = self.buffer.seekable() |
| 2049 | self._has_read1 = hasattr(self.buffer, 'read1') |
| 2050 | self._configure(encoding, errors, newline, |
| 2051 | line_buffering, write_through) |
| 2052 | |
| 2053 | def _check_newline(self, newline): |
| 2054 | if newline is not None and not isinstance(newline, str): |
nothing calls this directly
no test coverage detected