Skip to content

test.test_zlib.CompressObjectTestCase.test_flushes fails to parse ZLIB_VERSION with zlib-ng #112769

Closed
@hroncok

Description

@hroncok

Bug report

Bug description:

Hello. Fedora is switching from zlib to zlib-ng. https://fedoraproject.org/wiki/Changes/ZlibNGTransition

zlib-ng defines ZLIB_VERSION as "1.3.0.zlib-ng":

https://github.com/zlib-ng/zlib-ng/blob/f3211aba349a1d4781d0d41cb00d29fb8325af06/zlib.h.in#L61

And test.test_zlib.CompressObjectTestCase.test_flushes fails to parse it a sequence of dot-separated integers:

ver = tuple(int(v) for v in zlib.ZLIB_RUNTIME_VERSION.split('.'))

Traceback (most recent call last):
  File "/builddir/build/BUILD/Python-3.12.0/Lib/test/test_zlib.py", line 477, in test_flushes
    ver = tuple(int(v) for v in zlib.ZLIB_RUNTIME_VERSION.split('.'))
          ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/builddir/build/BUILD/Python-3.12.0/Lib/test/test_zlib.py", line 477, in <genexpr>
    ver = tuple(int(v) for v in zlib.ZLIB_RUNTIME_VERSION.split('.'))
                ^^^^^^
ValueError: invalid literal for int() with base 10: 'zlib-ng'

Another test in this file already handles this differently via 4c7108a:

v = zlib.ZLIB_RUNTIME_VERSION.split('-', 1)[0].split('.')
if len(v) < 4:
v.append('0')
elif not v[-1].isnumeric():
v[-1] = '0'
v = tuple(map(int, v))

This could be made a function, so both the tests that need to compare the version could re-use it.

CPython versions tested on:

3.12, 3.13, CPython main branch

Operating systems tested on:

Linux

Linked PRs

Metadata

Metadata

Assignees

No one assigned

    Labels

    testsTests in the Lib/test dirtype-bugAn unexpected behavior, bug, or error

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions