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

Method _read

tools/python-3.11.9-amd64/Lib/tarfile.py:531–556  ·  view source on GitHub ↗

Return size bytes from the stream.

(self, size)

Source from the content-addressed store, hash-verified

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

Callers 1

readMethod · 0.95

Calls 6

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

Tested by

no test coverage detected