Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commitd384813

Browse files
authored
gh-112769: test_zlib: Fix comparison of ZLIB_RUNTIME_VERSION with non-int suffix (GH-112771)
zlib-ng defines the version as "1.3.0.zlib-ng".
1 parentd109f63 commitd384813

File tree

2 files changed

+20
-12
lines changed

2 files changed

+20
-12
lines changed

‎Lib/test/test_zlib.py‎

Lines changed: 17 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,21 @@
1818
hasattr(zlib.decompressobj(),"copy"),
1919
'requires Decompress.copy()')
2020

21+
22+
def_zlib_runtime_version_tuple(zlib_version=zlib.ZLIB_RUNTIME_VERSION):
23+
# Register "1.2.3" as "1.2.3.0"
24+
# or "1.2.0-linux","1.2.0.f","1.2.0.f-linux"
25+
v=zlib_version.split('-',1)[0].split('.')
26+
iflen(v)<4:
27+
v.append('0')
28+
elifnotv[-1].isnumeric():
29+
v[-1]='0'
30+
returntuple(map(int,v))
31+
32+
33+
ZLIB_RUNTIME_VERSION_TUPLE=_zlib_runtime_version_tuple()
34+
35+
2136
# bpo-46623: On s390x, when a hardware accelerator is used, using different
2237
# ways to compress data with zlib can produce different compressed data.
2338
# Simplified test_pair() code:
@@ -473,9 +488,8 @@ def test_flushes(self):
473488
sync_opt= ['Z_NO_FLUSH','Z_SYNC_FLUSH','Z_FULL_FLUSH',
474489
'Z_PARTIAL_FLUSH']
475490

476-
ver=tuple(int(v)forvinzlib.ZLIB_RUNTIME_VERSION.split('.'))
477491
# Z_BLOCK has a known failure prior to 1.2.5.3
478-
ifver>= (1,2,5,3):
492+
ifZLIB_RUNTIME_VERSION_TUPLE>= (1,2,5,3):
479493
sync_opt.append('Z_BLOCK')
480494

481495
sync_opt= [getattr(zlib,opt)foroptinsync_opt
@@ -793,16 +807,7 @@ def test_large_unconsumed_tail(self, size):
793807

794808
deftest_wbits(self):
795809
# wbits=0 only supported since zlib v1.2.3.5
796-
# Register "1.2.3" as "1.2.3.0"
797-
# or "1.2.0-linux","1.2.0.f","1.2.0.f-linux"
798-
v=zlib.ZLIB_RUNTIME_VERSION.split('-',1)[0].split('.')
799-
iflen(v)<4:
800-
v.append('0')
801-
elifnotv[-1].isnumeric():
802-
v[-1]='0'
803-
804-
v=tuple(map(int,v))
805-
supports_wbits_0=v>= (1,2,3,5)
810+
supports_wbits_0=ZLIB_RUNTIME_VERSION_TUPLE>= (1,2,3,5)
806811

807812
co=zlib.compressobj(level=1,wbits=15)
808813
zlib15=co.compress(HAMLET_SCENE)+co.flush()
Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
The tests now correctly compare zlib version when
2+
:const:`zlib.ZLIB_RUNTIME_VERSION` contains non-integer suffixes. For
3+
example zlib-ng defines the version as ``1.3.0.zlib-ng``.

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp