MCPcopy Index your code
hub / github.com/RustPython/RustPython / _read

Method _read

Lib/tarfile.py:540–565  ·  view source on GitHub ↗

Return size bytes from the stream.

(self, size)

Source from the content-addressed store, hash-verified

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

Callers 1

readMethod · 0.95

Calls 7

__readMethod · 0.95
lenFunction · 0.85
ReadErrorClass · 0.70
readMethod · 0.45
decompressMethod · 0.45
appendMethod · 0.45
joinMethod · 0.45

Tested by

no test coverage detected