Skip to content

Commit d81eed6

Browse files
pythongh-155460: Make the multi-frame zstd test depend on whole-frame feeding
test_output_allocated_once_each_frame passed even without the whole-frame feeding in zstd.decompress(): its 2 MiB frame compresses to 459 bytes, so it fits whole into the 1 KiB that _decompress_all() feeds a later frame first. Use 2 MiB of zeros followed by 4 KiB of random bytes instead: the frame compresses to more than 1 KiB, and most of its output is decoded from its first KiB, which grows the output buffer unless the frame is fed whole. Co-Authored-By: Claude Opus 5.5 <[email protected]>
1 parent 431f0f1 commit d81eed6

1 file changed

Lines changed: 4 additions & 2 deletions

File tree

‎Lib/test/test_zstd.py‎

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1163,8 +1163,10 @@ def decompress_after_empty_input():
11631163
_peak_allocation(decompress_after_empty_input), len(data))
11641164

11651165
def test_output_allocated_once_each_frame(self):
1166-
# decompress() feeds every frame to its decompressor whole.
1167-
data = bytes(range(256)) * (8 * _1K) # 2 MiB
1166+
# decompress() feeds every frame to its decompressor whole. This
1167+
# frame is larger than the 1 KiB that a later frame would get first
1168+
# otherwise, and most of its output is decoded from that first KiB.
1169+
data = bytes(2 * _1M) + random.randbytes(4 * _1K)
11681170
frame = compress(data)
11691171
small = compress(b'small frame')
11701172
skippable = (0x184D2A50).to_bytes(4, 'little') + (4).to_bytes(4, 'little')

0 commit comments

Comments
 (0)