[Python] output_buffer_limit is not fully respected #567

Open
opened 2026-01-29 20:45:54 +00:00 by claunia · 1 comment
Owner

Originally created by @illia-v on GitHub (Nov 23, 2025).

Version 1.2.0 added output_buffer_limit – "If set, the output buffer will not grow once its size equal or exceeding that value."
While it does usually prevent decompressing the whole data at once, the output size is not limited by it.

import brotli

compressed = brotli.compress(b"x" * (10 * 2**20))  # 10 MiB

decompressor = brotli.Decompressor()
print(len(decompressor.process(compressed, output_buffer_limit=2**20)))  # Output 2_064_288, expected 1_048_576
print(len(decompressor.process(b"", output_buffer_limit=1024)))  # Output 32_752, expected 1024
print(len(decompressor.process(b"", output_buffer_limit=32_753)))  # Output 98_272, expected 32_753
Originally created by @illia-v on GitHub (Nov 23, 2025). Version 1.2.0 added `output_buffer_limit` – "If set, the output buffer will not grow once its size equal or exceeding that value." While it does usually prevent decompressing the whole data at once, the output size is not limited by it. ```python import brotli compressed = brotli.compress(b"x" * (10 * 2**20)) # 10 MiB decompressor = brotli.Decompressor() print(len(decompressor.process(compressed, output_buffer_limit=2**20))) # Output 2_064_288, expected 1_048_576 print(len(decompressor.process(b"", output_buffer_limit=1024))) # Output 32_752, expected 1024 print(len(decompressor.process(b"", output_buffer_limit=32_753))) # Output 98_272, expected 32_753 ```
Author
Owner

@illia-v commented on GitHub (Nov 23, 2025):

FYI, brotlicffi v1.2.0.0 built on top of this library outputs the exact requested amount of bytes
https://github.com/python-hyper/brotlicffi/pull/207

@illia-v commented on GitHub (Nov 23, 2025): FYI, brotlicffi v1.2.0.0 built on top of this library outputs the exact requested amount of bytes https://github.com/python-hyper/brotlicffi/pull/207
Sign in to join this conversation.
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: starred/brotli#567