Gzip
Gzip is a lossless compressed-file format whose file consists of a sequence of members, each carrying a compressed data stream and a trailer with CRC32 and uncompressed size modulo 2^32.
A member is a compression-format unit, not necessarily a named TAR entry or the full intended recovery object. RFC 1952 defines the format; a surviving valid member cannot reveal that a different complete member was removed. [1]
Python gzip.decompress supports concatenated members. In contrast, zlib's inflate interface stops at a member boundary; callers must continue with the remaining input when multiple members are intended. Python's object API exposes eof and unused_data for different questions: terminal state and bytes after that stream. [2] [3] [5]
In Hesela's 42 bounded operations on CPython 3.12.3 and zlib 1.3, reading exactly 65,536 expected bytes then closing returned correct bytes without an error from a gzip whose CRC was deliberately damaged. Reading through EOF detected the discrepancy after returning the same payload. Removing one final trailer byte likewise escaped the exact-length read; decompressobj plus flush returned all bytes but left eof false. These are observations at recorded call sizes, not guarantees of error timing. [6]
On an intact two-member input, the single-member zlib call returned 65,536 of the required 98,304 bytes without an exception. Removing the second member entirely let whole-input gzip decoding succeed, but failed the separately fixed full-payload comparison. Require intended decoding coverage, terminal status and independent content expectations. A successful read or close alone is not whole-archive verification. [6]
Relations
- related
- archive-member, backup-manifest, checksum, zstandard, restore-test
Citations
- RFC 1952: GZIP file format specification 4.3, sections 2.2, 2.3.1 and 2.3.1.2
- Python 3.12 gzip documentation: multi-member decompression and errors
- Python 3.12 zlib documentation: eof, unused_data and unconsumed_tail
- zlib v1.3 public interface: inflate stops at a gzip member boundary
- Hesela: 42 gzip API operations distinguish trailer checks, member completion and expected content
Further reading
Sources & caveats
- Primary-source synthesis plus seven synthetic fixtures, not field reliability evidence. No third-party payload or source code redistributed.
- Reproduction: https://hesela.dev/research/gzip-read-coverage.py ; observations: https://hesela.dev/research/gzip-read-coverage.json . Python standard library only; caller-returned bytes, not physical I/O.
Published by Hesela team · Updated
Report a correction · Editorial standards · Reuse guidance
Cite this page
Hesela team. Gzip. Hesela. 2026-10-18. https://hesela.dev/terms/gzip/