Skip to content

Add BZIP2, LZMA, and ZSTANDARD decompression support to NetZipFile#291

Merged
davidfstr merged 5 commits intomainfrom
copilot/add-support-for-all-compression-methods
Mar 10, 2026
Merged

Add BZIP2, LZMA, and ZSTANDARD decompression support to NetZipFile#291
davidfstr merged 5 commits intomainfrom
copilot/add-support-for-all-compression-methods

Conversation

Copy link
Copy Markdown
Contributor

Copilot AI commented Mar 9, 2026

NetZipFile only supported STORED (0) and DEFLATE (8), leaving three compression methods supported by Python's zipfile module unhandled.

Changes

  • New reader classes_Bzip2Reader (method 12), _LzmaReader (method 14), and _ZstdReader (method 93), each following the same buffered io.RawIOBase pattern as the existing _DeflateReader
  • LZMA header handling_LzmaZipDecompressor parses the 4-byte ZIP LZMA header (version + properties size), extracts LZMA1 filter properties, then initializes lzma.LZMADecompressor(FORMAT_RAW, ...) — mirrors CPython's own zipfile.LZMADecompressor
  • ZSTD availability guardcompression.zstd is only available on Python 3.14+; raises RuntimeError at runtime if the entry requires ZSTD on an older interpreter
  • _open_entry_data dispatch — extended elif chain to route methods 12, 14, and 93 to the new readers
  • Tests — one test per new method; ZSTD test is skipif Python < 3.14; helper zip-builder functions added alongside the existing _create_deflate_zip
Original prompt

Currently #file:netzipfile.py supports only the STORED and DEFLATE compression methods: #file:netzipfile.py:355-370

Please add support for all compression methods that Python's latest stable/released version of the zipfile module supports. Consult the CPython source code if unsure.

Related automated tests, to extend:

  • #file:test_netzipfile.py:14-41

Suggest implement new compression methods similar to how DEFLATE support was added.

The user has attached the following file paths as relevant context:

  • src/crystal/util/netzipfile.py
  • .github/copilot-instructions.md

Created from VS Code.


💡 You can make Copilot smarter by setting up custom instructions, customizing its development environment and configuring Model Context Protocol (MCP) servers. Learn more Copilot coding agent tips in the docs.

Co-authored-by: davidfstr <764688+davidfstr@users.noreply.github.com>
Copilot AI changed the title [WIP] Add support for all compression methods in netzipfile Add BZIP2, LZMA, and ZSTANDARD decompression support to NetZipFile Mar 9, 2026
@davidfstr davidfstr marked this pull request as ready for review March 10, 2026 01:01
@davidfstr davidfstr merged commit c4b79cc into main Mar 10, 2026
7 of 8 checks passed
@davidfstr davidfstr deleted the copilot/add-support-for-all-compression-methods branch March 13, 2026 01:49
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants