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

Method read

Lib/_pyio.py:606–623  ·  view source on GitHub ↗

Read and return up to size bytes, where size is an int. Returns an empty bytes object on EOF, or None if the object is set not to block and has no data to read.

(self, size=-1)

Source from the content-addressed store, hash-verified

604 # a subclass doesn't implement either.)
605
606 def read(self, size=-1):
607 """Read and return up to size bytes, where size is an int.
608
609 Returns an empty bytes object on EOF, or None if the object is
610 set not to block and has no data to read.
611 """
612 if size is None:
613 size = -1
614 if size < 0:
615 return self.readall()
616 b = bytearray(size.__index__())
617 n = self.readinto(b)
618 if n is None:
619 return None
620 if n < 0 or n > len(b):
621 raise ValueError(f"readinto returned {n} outside buffer size {len(b)}")
622 del b[n:]
623 return b.take_bytes()
624
625 def readall(self):
626 """Read until EOF, using multiple read() call."""

Callers 1

readallMethod · 0.95

Calls 4

readallMethod · 0.95
readintoMethod · 0.95
take_bytesMethod · 0.80
__index__Method · 0.45

Tested by

no test coverage detected