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

Method _read

Lib/tarfile.py:538–563  ·  view source on GitHub ↗

Return size bytes from the stream.

(self, size)

Source from the content-addressed store, hash-verified

536 return buf
537
538 def _read(self, size):
539 """Return size bytes from the stream.
540 """
541 if self.comptype == "tar":
542 return self.__read(size)
543
544 c = len(self.dbuf)
545 t = [self.dbuf]
546 while c < size:
547 # Skip underlying buffer to avoid unaligned double buffering.
548 if self.buf:
549 buf = self.buf
550 self.buf = b""
551 else:
552 buf = self.fileobj.read(self.bufsize)
553 if not buf:
554 break
555 try:
556 buf = self.cmp.decompress(buf)
557 except self.exception as e:
558 raise ReadError("invalid compressed data") from e
559 t.append(buf)
560 c += len(buf)
561 t = b"".join(t)
562 self.dbuf = t[size:]
563 return t[:size]
564
565 def __read(self, size):
566 """Return size bytes from stream. If internal buffer is empty,

Callers 1

readMethod · 0.95

Calls 6

__readMethod · 0.95
decompressMethod · 0.80
ReadErrorClass · 0.70
readMethod · 0.45
appendMethod · 0.45
joinMethod · 0.45

Tested by

no test coverage detected