MCPcopy Create free account
hub / github.com/RT-Thread/env-windows / TextIOWrapper

Class TextIOWrapper

tools/python-3.11.9-amd64/Lib/_pyio.py:1987–2661  ·  view source on GitHub ↗

r"""Character and line based layer over a BufferedIOBase object, buffer. encoding gives the name of the encoding that the stream will be decoded or encoded with. It defaults to locale.getencoding(). errors determines the strictness of encoding and decoding (see the codecs.reg

Source from the content-addressed store, hash-verified

1985
1986
1987class TextIOWrapper(TextIOBase):
1988
1989 r"""Character and line based layer over a BufferedIOBase object, buffer.
1990
1991 encoding gives the name of the encoding that the stream will be
1992 decoded or encoded with. It defaults to locale.getencoding().
1993
1994 errors determines the strictness of encoding and decoding (see the
1995 codecs.register) and defaults to "strict".
1996
1997 newline can be None, '', '\n', '\r', or '\r\n'. It controls the
1998 handling of line endings. If it is None, universal newlines is
1999 enabled. With this enabled, on input, the lines endings '\n', '\r',
2000 or '\r\n' are translated to '\n' before being returned to the
2001 caller. Conversely, on output, '\n' is translated to the system
2002 default line separator, os.linesep. If newline is any other of its
2003 legal values, that newline becomes the newline when the file is read
2004 and it is returned untranslated. On output, '\n' is converted to the
2005 newline.
2006
2007 If line_buffering is True, a call to flush is implied when a call to
2008 write contains a newline character.
2009 """
2010
2011 _CHUNK_SIZE = 2048
2012
2013 # Initialize _buffer as soon as possible since it's used by __del__()
2014 # which calls close()
2015 _buffer = None
2016
2017 # The write_through argument has no effect here since this
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

Callers 7

openFunction · 0.90
parseMethod · 0.90
_io_wrapperFunction · 0.90
_io_wrapperFunction · 0.90
_io_wrapperFunction · 0.90
openFunction · 0.85

Calls

no outgoing calls