Skip to content

Commit b0fd935

Browse files
bpo-32682: Improve libz version parsing in test_zilb (GH-5347)
(cherry picked from commit 4c7108a) Co-authored-by: pmp-p <[email protected]>
1 parent 2a93fae commit b0fd935

File tree

1 file changed

+9
-4
lines changed

1 file changed

+9
-4
lines changed

Lib/test/test_zlib.py

Lines changed: 9 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -751,10 +751,15 @@ def test_large_unconsumed_tail(self, size):
751751
def test_wbits(self):
752752
# wbits=0 only supported since zlib v1.2.3.5
753753
# Register "1.2.3" as "1.2.3.0"
754-
v = (zlib.ZLIB_RUNTIME_VERSION + ".0").split(".", 4)
755-
supports_wbits_0 = int(v[0]) > 1 or int(v[0]) == 1 \
756-
and (int(v[1]) > 2 or int(v[1]) == 2
757-
and (int(v[2]) > 3 or int(v[2]) == 3 and int(v[3]) >= 5))
754+
# or "1.2.0-linux","1.2.0.f","1.2.0.f-linux"
755+
v = zlib.ZLIB_RUNTIME_VERSION.split('-', 1)[0].split('.')
756+
if len(v) < 4:
757+
v.append('0')
758+
elif not v[-1].isnumeric():
759+
v[-1] = '0'
760+
761+
v = tuple(map(int, v))
762+
supports_wbits_0 = v >= (1, 2, 3, 5)
758763

759764
co = zlib.compressobj(level=1, wbits=15)
760765
zlib15 = co.compress(HAMLET_SCENE) + co.flush()

0 commit comments

Comments
 (0)