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

Method _read_eof

Lib/gzip.py:596–615  ·  view source on GitHub ↗
(self)

Source from the content-addressed store, hash-verified

594 return uncompress
595
596 def _read_eof(self):
597 # We've read to the end of the file
598 # We check that the computed CRC and size of the
599 # uncompressed data matches the stored values. Note that the size
600 # stored is the true file size mod 2**32.
601 crc32, isize = struct.unpack("<II", _read_exact(self._fp, 8))
602 if crc32 != self._crc:
603 raise BadGzipFile("CRC check failed %s != %s" % (hex(crc32),
604 hex(self._crc)))
605 elif isize != (self._stream_size & 0xffffffff):
606 raise BadGzipFile("Incorrect length of data produced")
607
608 # Gzip files can be padded with zeroes and still have archives.
609 # Consume all zero bytes and set the file position to the first
610 # non-zero byte. See http://www.gzip.org/#faq8
611 c = b"\x00"
612 while c == b"\x00":
613 c = self._fp.read(1)
614 if c:
615 self._fp.prepend(c)
616
617 def _rewind(self):
618 super()._rewind()

Callers 1

readMethod · 0.95

Calls 5

_read_exactFunction · 0.85
BadGzipFileClass · 0.85
unpackMethod · 0.80
prependMethod · 0.80
readMethod · 0.45

Tested by

no test coverage detected