(self)
| 527 | self._stream_size = self._stream_size + len(data) |
| 528 | |
| 529 | def _read_eof(self): |
| 530 | # We've read to the end of the file |
| 531 | # We check that the computed CRC and size of the |
| 532 | # uncompressed data matches the stored values. Note that the size |
| 533 | # stored is the true file size mod 2**32. |
| 534 | crc32, isize = struct.unpack("<II", _read_exact(self._fp, 8)) |
| 535 | if crc32 != self._crc: |
| 536 | raise BadGzipFile("CRC check failed %s != %s" % (hex(crc32), |
| 537 | hex(self._crc))) |
| 538 | elif isize != (self._stream_size & 0xffffffff): |
| 539 | raise BadGzipFile("Incorrect length of data produced") |
| 540 | |
| 541 | # Gzip files can be padded with zeroes and still have archives. |
| 542 | # Consume all zero bytes and set the file position to the first |
| 543 | # non-zero byte. See http://www.gzip.org/#faq8 |
| 544 | c = b"\x00" |
| 545 | while c == b"\x00": |
| 546 | c = self._fp.read(1) |
| 547 | if c: |
| 548 | self._fp.prepend(c) |
| 549 | |
| 550 | def _rewind(self): |
| 551 | super()._rewind() |
no test coverage detected