Skip to content

Commit e795310

Browse files
committed
Fix the known-bug tests on debug builds and zlib-ng
The test pinning gh-160001 expects a SystemError, but in a debug build the missing exception trips a C assertion in the call machinery before the SystemError is raised, which aborts the test worker. All CI builds are debug builds, so the test is skipped there until the bug is fixed. The gzip examples for gh-159999 also depend on where inflate stops consuming input, and none of them triggered the bug with zlib-ng, which the Windows builds use. This adds an example found against zlib-ng 2.2.4 in zlib-compat mode; the zlib wrapper and raw deflate examples already fail with both libraries. The comments now also reference the filed issues.
1 parent 90fd254 commit e795310

1 file changed

Lines changed: 19 additions & 7 deletions

File tree

‎Lib/test/test_compression_property.py‎

Lines changed: 19 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -457,7 +457,8 @@ def test_invalid_input(self, garbage, data, index, byte, sizes,
457457

458458
class _BZ2NeedsInputBug:
459459
# bz2 reports needs_input=True as soon as its input buffer is empty, even
460-
# when max_length cut the output short and more of it is pending.
460+
# when max_length cut the output short and more of it is pending
461+
# (gh-159999).
461462
@unittest.expectedFailure
462463
@hypothesis.given(
463464
data=data_strategy,
@@ -470,8 +471,11 @@ def test_needs_input_means_drained(self, data, sizes, max_lengths):
470471

471472

472473
class _ZlibNeedsInputBug:
473-
# zlib._ZlibDecompressor has the same needs_input problem as bz2. One
474-
# example per wbits variant: zlib wrapper, raw deflate, gzip wrapper.
474+
# zlib._ZlibDecompressor has the same needs_input problem as bz2
475+
# (gh-159999). The examples depend on where the compressor puts block
476+
# boundaries, so there are several: at least one must fail for each
477+
# wbits variant (zlib wrapper, raw deflate, gzip wrapper) with both zlib
478+
# and zlib-ng.
475479
@unittest.expectedFailure
476480
@hypothesis.given(
477481
data=data_strategy,
@@ -486,15 +490,20 @@ class _ZlibNeedsInputBug:
486490
sizes=[34],
487491
max_lengths=[20],
488492
)
493+
@hypothesis.example(
494+
data=b"\x00\x00\x00\x00\x01\x00\x00\x00\x02\x00\x00\x03" * 2,
495+
sizes=[25],
496+
max_lengths=[12],
497+
)
489498
def test_needs_input_means_drained(self, data, sizes, max_lengths):
490499
self._check_needs_input_means_drained(data, sizes, max_lengths)
491500

492501

493502
# liblzma reports an error when two consecutive calls can make no progress,
494503
# which lzma.LZMADecompressor lets through as LZMAError("Insufficient buffer
495-
# space") for two max_length=0 calls in a row with nothing buffered. The
496-
# broad lzma tests avoid max_length=0 so that they keep checking everything
497-
# else; test_repeated_max_length_zero pins the bug.
504+
# space") for two max_length=0 calls in a row with nothing buffered
505+
# (gh-160000). The broad lzma tests avoid max_length=0 so that they keep
506+
# checking everything else; test_repeated_max_length_zero pins the bug.
498507
lzma_max_length_strategy = st.integers(1, 64) | st.just(-1)
499508
lzma_max_lengths_strategy = st.lists(lzma_max_length_strategy, max_size=16)
500509

@@ -784,7 +793,10 @@ def test_raw_deflate(self, data, zdict, level):
784793

785794
# _ZlibDecompressor only applies zdict up front for raw deflate; for a
786795
# zlib-wrapped stream it hits Z_NEED_DICT and returns NULL without
787-
# setting an exception, which surfaces as SystemError.
796+
# setting an exception (gh-160001). That surfaces as SystemError in a
797+
# release build and as a fatal C assertion in a debug build, so the test
798+
# can only run in the former.
799+
@unittest.skipIf(support.Py_DEBUG, "gh-160001 aborts debug builds")
788800
@unittest.expectedFailure
789801
@hypothesis.given(
790802
data=data_strategy,

0 commit comments

Comments
 (0)