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

Commit9796577

Browse files
hroncokbefeleme
authored andcommitted
00419:pythongh-112769: test_zlib: Fix comparison of ZLIB_RUNTIME_VERSION with non-int suffix (pythonGH-112771) (pythonGH-112774)
zlib-ng defines the version as "1.3.0.zlib-ng".(cherry picked from commitd384813)Co-authored-by: Miro Hrončok <miro@hroncok.cz>
1 parentf1d949a commit9796577

File tree

1 file changed

+16
-12
lines changed

1 file changed

+16
-12
lines changed

‎Lib/test/test_zlib.py‎

Lines changed: 16 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,20 @@
1717
'requires Decompress.copy()')
1818

1919

20+
def_zlib_runtime_version_tuple(zlib_version=zlib.ZLIB_RUNTIME_VERSION):
21+
# Register "1.2.3" as "1.2.3.0"
22+
# or "1.2.0-linux","1.2.0.f","1.2.0.f-linux"
23+
v=zlib_version.split('-',1)[0].split('.')
24+
iflen(v)<4:
25+
v.append('0')
26+
elifnotv[-1].isnumeric():
27+
v[-1]='0'
28+
returntuple(map(int,v))
29+
30+
31+
ZLIB_RUNTIME_VERSION_TUPLE=_zlib_runtime_version_tuple()
32+
33+
2034
classVersionTestCase(unittest.TestCase):
2135

2236
deftest_library_version(self):
@@ -437,9 +451,8 @@ def test_flushes(self):
437451
sync_opt= ['Z_NO_FLUSH','Z_SYNC_FLUSH','Z_FULL_FLUSH',
438452
'Z_PARTIAL_FLUSH']
439453

440-
ver=tuple(int(v)forvinzlib.ZLIB_RUNTIME_VERSION.split('.'))
441454
# Z_BLOCK has a known failure prior to 1.2.5.3
442-
ifver>= (1,2,5,3):
455+
ifZLIB_RUNTIME_VERSION_TUPLE>= (1,2,5,3):
443456
sync_opt.append('Z_BLOCK')
444457

445458
sync_opt= [getattr(zlib,opt)foroptinsync_opt
@@ -768,16 +781,7 @@ def test_large_unconsumed_tail(self, size):
768781

769782
deftest_wbits(self):
770783
# wbits=0 only supported since zlib v1.2.3.5
771-
# Register "1.2.3" as "1.2.3.0"
772-
# or "1.2.0-linux","1.2.0.f","1.2.0.f-linux"
773-
v=zlib.ZLIB_RUNTIME_VERSION.split('-',1)[0].split('.')
774-
iflen(v)<4:
775-
v.append('0')
776-
elifnotv[-1].isnumeric():
777-
v[-1]='0'
778-
779-
v=tuple(map(int,v))
780-
supports_wbits_0=v>= (1,2,3,5)
784+
supports_wbits_0=ZLIB_RUNTIME_VERSION_TUPLE>= (1,2,3,5)
781785

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

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp