Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 4 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,10 @@

All notable changes to this project will be documented in this file.

## Unreleased

- Fix issue with `max_length` not always being respected in `EndlessZstdDecompressor`

## 0.20.0 (October 11, 2026)

- Support for 3.15 and PyPy 3.12
Expand Down
10 changes: 6 additions & 4 deletions src/pyzstd/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -368,20 +368,22 @@ def decompress(self, data: Buffer, max_length: int = -1) -> bytes:
raise TypeError
self._buffer += data
self._at_frame_edge &= not self._buffer
out = b""
out_chunks: list[bytes] = []
while True:
try:
out += self._decompressor.decompress(self._buffer, max_length)
out_chunks.append(
self._decompressor.decompress(self._buffer, max_length)
)
except ZstdError:
self._reset()
raise
if self._decompressor.eof:
self._reset(self._decompressor.unused_data)
max_length -= len(out)
max_length -= len(out_chunks[-1])
else:
self._buffer = b""
break
return out
return b"".join(out_chunks)

@property
def at_frame_edge(self) -> bool:
Expand Down
Loading