Skip to content

Commit 95b58f7

Browse files
Address review comments
* Register collect_bz2() and collect_lzma() in pythoninfo's collect_info(). * Do not assume a particular suffix of bz2.bzlib_version: libbz2-rs reports "1.1.0-libbz2-rs-sys-0.2.5" where bzip2 reports "1.0.8, 13-Jul-2019". * Document ZLIB_RUNTIME_VERSION and zlib_version as a single entry and tell in which version each of them was added. * Tell which fields the runtime *_version_info named tuples have by referring to their compile-time counterparts. * Remove a line duplicated when applying a suggestion for ZLIB_VERSION_INFO. * Fix indentation, alignment and line lengths of the added code. Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
1 parent 6e04c64 commit 95b58f7

13 files changed

Lines changed: 53 additions & 34 deletions

File tree

Doc/library/compression.zstd.rst

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -860,7 +860,9 @@ the following constants:
860860

861861
.. data:: zstd_version_info
862862

863-
A named tuple containing the zstd library version actually loaded by the interpreter.
863+
A named tuple containing the version of the zstd library
864+
actually loaded by the interpreter,
865+
with the same fields as :const:`ZSTD_VERSION_INFO`.
864866

865867
.. versionchanged:: next
866868
It is now a named tuple.

Doc/library/lzma.rst

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -351,7 +351,9 @@ the following constants:
351351

352352
.. data:: lzma_version_info
353353

354-
A named tuple containing the lzma library version actually loaded by the interpreter.
354+
A named tuple containing the version of the lzma library
355+
actually loaded by the interpreter,
356+
with the same fields as :const:`LZMA_VERSION_INFO`.
355357

356358
.. versionadded:: next
357359

Doc/library/zlib.rst

Lines changed: 11 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -483,13 +483,15 @@ the following constants:
483483

484484

485485
.. data:: ZLIB_RUNTIME_VERSION
486-
.. data:: zlib_version
486+
zlib_version
487487

488488
The version string of the zlib library actually loaded by the interpreter.
489489

490490
.. versionadded:: 3.3
491-
.. versionchanged:: next
492-
Added alias :const:`!zlib_version`.
491+
The :const:`!ZLIB_RUNTIME_VERSION` constant.
492+
493+
.. versionadded:: next
494+
The :const:`!zlib_version` alias.
493495

494496

495497
.. data:: ZLIB_VERSION_INFO
@@ -498,7 +500,6 @@ the following constants:
498500
version that was used for building the module:
499501
*major*, *minor*, *revision*, and *subversion*.
500502
All values are integers.
501-
The components can also be accessed by name, so ``zlib.VERSION_INFO[0]``
502503
The components can also be accessed by name, so ``zlib.ZLIB_VERSION_INFO[0]``
503504
is equivalent to ``zlib.ZLIB_VERSION_INFO.major`` and so on.
504505
This may be different from the zlib library actually used at runtime, which
@@ -509,7 +510,9 @@ the following constants:
509510

510511
.. data:: zlib_version_info
511512

512-
A named tuple containing the zlib library version actually loaded by the interpreter.
513+
A named tuple containing the version of the zlib library
514+
actually loaded by the interpreter,
515+
with the same fields as :const:`ZLIB_VERSION_INFO`.
513516

514517
.. versionadded:: next
515518

@@ -529,8 +532,9 @@ the module:
529532

530533
.. data:: ZLIBNG_VERSION_INFO
531534

532-
A named tuple containing the version of the zlib-ng library that was
533-
used for building the module if zlib-ng was used.
535+
A named tuple containing the three components of the zlib-ng library
536+
version that was used for building the module:
537+
*major*, *minor*, and *revision*. All values are integers.
534538

535539
.. versionadded:: next
536540

Doc/whatsnew/3.16.rst

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -372,6 +372,7 @@ Add :meth:`~ipaddress.IPv4Network.next_network` and
372372
:meth:`~ipaddress.IPv6Network.next_network` methods to find the next nearest
373373
network with a specific prefix size.
374374

375+
375376
logging
376377
-------
377378

Lib/bz2.py

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,8 @@
55
"""
66

77
__all__ = ["BZ2File", "BZ2Compressor", "BZ2Decompressor",
8-
"open", "compress", "decompress", "bzlib_version", "bzlib_version_info"]
8+
"open", "compress", "decompress",
9+
"bzlib_version", "bzlib_version_info"]
910

1011
__author__ = "Nadeem Vawda <nadeem.vawda@gmail.com>"
1112

@@ -14,7 +15,8 @@
1415
import io
1516
import os
1617

17-
from _bz2 import BZ2Compressor, BZ2Decompressor, bzlib_version, bzlib_version_info
18+
from _bz2 import (BZ2Compressor, BZ2Decompressor,
19+
bzlib_version, bzlib_version_info)
1820

1921

2022
# Value 0 no longer used

Lib/test/pythoninfo.py

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1354,6 +1354,7 @@ def collect_info(info):
13541354
collect_urandom,
13551355

13561356
collect_builtins,
1357+
collect_bz2,
13571358
collect_cc,
13581359
collect_curses,
13591360
collect_datetime,
@@ -1364,6 +1365,7 @@ def collect_info(info):
13641365
collect_gdbm,
13651366
collect_get_config,
13661367
collect_locale,
1368+
collect_lzma,
13671369
collect_os,
13681370
collect_platform,
13691371
collect_pwd,

Lib/test/test_bz2.py

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1244,7 +1244,9 @@ def test_bzlib_version(self):
12441244
self.assertGreaterEqual(v.minor, 0)
12451245
self.assertGreaterEqual(v.patch, 0)
12461246

1247-
self.assertEqual(bz2.bzlib_version.split(',')[0], '%d.%d.%d' % v)
1247+
# The version string can have a suffix, e.g. "1.0.8, 13-Jul-2019"
1248+
# for bzip2 or "1.1.0-libbz2-rs-sys-0.2.5" for libbz2-rs.
1249+
self.assertStartsWith(bz2.bzlib_version, '%d.%d.%d' % v)
12481250

12491251

12501252
def tearDownModule():

Lib/test/test_lzma.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1536,7 +1536,7 @@ def _test_lzma_version(self, v, string):
15361536
if v.stability == 'stable':
15371537
self.assertEqual(string, '%d.%d.%d' % v[:3])
15381538
else:
1539-
self.assertTrue(string.startswith('%d.%d.%d%s' % v))
1539+
self.assertStartsWith(string, '%d.%d.%d%s' % v)
15401540

15411541
def test_lzma_version(self):
15421542
if support.verbose:

Lib/test/test_zlib.py

Lines changed: 8 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -100,9 +100,11 @@ def test_zlib_version(self):
100100
print(f'ZLIB_VERSION_INFO = {zlib.ZLIB_VERSION_INFO}', flush=True)
101101
print(f'zlib_version_info = {zlib.zlib_version_info}', flush=True)
102102
self._test_zlib_version(zlib.ZLIB_VERSION_INFO)
103-
self.assertEqual(zlib.ZLIB_VERSION_INFO, _parse_version(zlib.ZLIB_VERSION))
103+
self.assertEqual(zlib.ZLIB_VERSION_INFO,
104+
_parse_version(zlib.ZLIB_VERSION))
104105
self._test_zlib_version(zlib.zlib_version_info)
105-
self.assertEqual(zlib.zlib_version_info, _parse_version(zlib.zlib_version))
106+
self.assertEqual(zlib.zlib_version_info,
107+
_parse_version(zlib.zlib_version))
106108
self.assertEqual(zlib.ZLIB_RUNTIME_VERSION, zlib.zlib_version)
107109

108110
def _test_zlibng_version(self, v):
@@ -125,9 +127,11 @@ def _test_zlibng_version(self, v):
125127
def test_zlibng_version(self):
126128
if support.verbose:
127129
print(f'ZLIBNG_VERSION = {zlib.ZLIBNG_VERSION}', flush=True)
128-
print(f'ZLIBNG_VERSION_INFO = {zlib.ZLIBNG_VERSION_INFO}', flush=True)
130+
print(f'ZLIBNG_VERSION_INFO = {zlib.ZLIBNG_VERSION_INFO}',
131+
flush=True)
129132
self._test_zlibng_version(zlib.ZLIBNG_VERSION_INFO)
130-
self.assertEqual(zlib.ZLIBNG_VERSION, '%d.%d.%d' % zlib.ZLIBNG_VERSION_INFO)
133+
self.assertEqual(zlib.ZLIBNG_VERSION,
134+
'%d.%d.%d' % zlib.ZLIBNG_VERSION_INFO)
131135

132136

133137
class ChecksumTestCase(unittest.TestCase):

Modules/_bz2module.c

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -761,9 +761,9 @@ static PyStructSequence_Field bzlib_version_fields[] = {
761761
};
762762

763763
static PyStructSequence_Desc bzlib_version_desc = {
764-
"_bz2.bzlib_version_info", /* name */
765-
bzlib_version__doc__, /* doc */
766-
bzlib_version_fields, /* fields */
764+
"_bz2.bzlib_version_info", /* name */
765+
bzlib_version__doc__, /* doc */
766+
bzlib_version_fields, /* fields */
767767
3
768768
};
769769

0 commit comments

Comments
 (0)