Skip to content

[3.15] gh-156002: Keep reading through monkey-patched zipfile decompressors (GH-157180) - #157268

Open
encukou wants to merge 1 commit into
python:3.15from
encukou:backport-e2311cf-3.15
Open

[3.15] gh-156002: Keep reading through monkey-patched zipfile decompressors (GH-157180)#157268
encukou wants to merge 1 commit into
python:3.15from
encukou:backport-e2311cf-3.15

Conversation

@encukou

@encukou encukou commented Sep 10, 2026

Copy link
Copy Markdown
Member

GH-156003 made ZipExtFile._read1() call decompress(data, max_length) on non-deflate decompressors and consult needs_input before reading more. A decompressor installed by monkey-patching _get_decompressor() (as projects like zipfile-zstd, zipfile-deflate64, ... do) may support neither, and every read through it then failed with AttributeError.

  • Make LZMADecompressor.needs_input public to simplify implementation.
  • Make the needs_input attribute optional.
  • If decompress() fails with TypeError, try again with one argument.
  • Add tests for future changes, so we can make informed decisions about breaking monkey-patchers. (cherry picked from commit e2311cf)

The backport omits emitting a DeprecationWarning.

…ecompressors (pythonGH-157180)

pythonGH-156003 made ZipExtFile._read1() call decompress(data, max_length) on
non-deflate decompressors and consult needs_input before reading more. A
decompressor installed by monkey-patching _get_decompressor() (as projects
like zipfile-zstd, zipfile-deflate64, ... do) may support neither, and every read
through it then failed with AttributeError.

- Make LZMADecompressor.needs_input public to simplify implementation.
- Make the needs_input attribute optional.
- If `decompress()` fails with TypeError, try again with one argument.
- Since the fallback to one-argument call is a maintenance burden, raise
  DeprecationWarning.
- Add tests for future changes, so we can make informed decisions
  about breaking monkey-patchers.
(cherry picked from commit e2311cf)

Co-authored-by: rasmusfaber <rfaber@gmail.com>
Co-authored-by: Petr Viktorin <encukou@gmail.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants