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

Method read

Lib/_pyio.py:923–944  ·  view source on GitHub ↗
(self, size=-1)

Source from the content-addressed store, hash-verified

921 super().close()
922
923 def read(self, size=-1):
924 if self.closed:
925 raise ValueError("read from closed file")
926 if size is None:
927 size = -1
928 else:
929 try:
930 size_index = size.__index__
931 except AttributeError:
932 raise TypeError(f"{size!r} is not an integer")
933 else:
934 size = size_index()
935
936 with self._lock:
937 if size < 0:
938 size = len(self._buffer)
939 if len(self._buffer) <= self._pos:
940 return b""
941 newpos = min(len(self._buffer), self._pos + size)
942 b = self._buffer[self._pos : newpos]
943 self._pos = newpos
944 return bytes(b)
945
946 def read1(self, size=-1):
947 """This is the same as read.

Callers 15

_genopsFunction · 0.95
read1Method · 0.95
_dump_messageMethod · 0.95
_install_messageMethod · 0.95
dumpsMethod · 0.95
dumpsMethod · 0.95
test_xml_c14n2Method · 0.95

Calls

no outgoing calls

Tested by 12

dumpsMethod · 0.76
dumpsMethod · 0.76
test_xml_c14n2Method · 0.76
test_fileobjMethod · 0.76
test_from_fileMethod · 0.76