Skip to content

Commit a6ddf46

Browse files
hroncokhrnciar
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 commit d384813)
1 parent 128192c commit a6ddf46

File tree

1 file changed

+14
-0
lines changed

1 file changed

+14
-0
lines changed

Lib/test/test_zlib.py

+14
Original file line numberDiff line numberDiff line change
@@ -30,6 +30,20 @@ def _zlib_runtime_version_tuple(zlib_version=zlib.ZLIB_RUNTIME_VERSION):
3030
ZLIB_RUNTIME_VERSION_TUPLE = _zlib_runtime_version_tuple()
3131

3232

33+
def _zlib_runtime_version_tuple(zlib_version=zlib.ZLIB_RUNTIME_VERSION):
34+
# Register "1.2.3" as "1.2.3.0"
35+
# or "1.2.0-linux","1.2.0.f","1.2.0.f-linux"
36+
v = zlib_version.split('-', 1)[0].split('.')
37+
if len(v) < 4:
38+
v.append('0')
39+
elif not v[-1].isnumeric():
40+
v[-1] = '0'
41+
return tuple(map(int, v))
42+
43+
44+
ZLIB_RUNTIME_VERSION_TUPLE = _zlib_runtime_version_tuple()
45+
46+
3347
class VersionTestCase(unittest.TestCase):
3448

3549
def test_library_version(self):

0 commit comments

Comments
 (0)