Skip to content

Commit bac4eda

Browse files
authored
gh-112346: Document the OS byte in gzip.compress output change in 3.11 (#120480)
gh-112346: Describe the "os" byte in gzip output change.
1 parent bd4516d commit bac4eda

File tree

2 files changed

+18
-1
lines changed

2 files changed

+18
-1
lines changed

Doc/library/gzip.rst

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -196,7 +196,9 @@ The module defines the following items:
196196
.. versionchanged:: 3.11
197197
Speed is improved by compressing all data at once instead of in a
198198
streamed fashion. Calls with *mtime* set to ``0`` are delegated to
199-
:func:`zlib.compress` for better speed.
199+
:func:`zlib.compress` for better speed. In this situation the
200+
output may contain a gzip header "OS" byte value other than 255
201+
"unknown" as supplied by the underlying zlib implementation.
200202

201203
.. versionchanged:: 3.13
202204
The gzip header OS byte is guaranteed to be set to 255 when this function

Doc/whatsnew/3.11.rst

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -768,6 +768,21 @@ functools
768768
(Contributed by Yurii Karabas in :issue:`46014`.)
769769

770770

771+
.. _whatsnew311-gzip:
772+
773+
gzip
774+
----
775+
776+
* The :func:`gzip.compress` function is now faster when used with the
777+
**mtime=0** argument as it delegates the compression entirely to a single
778+
:func:`zlib.compress` operation. There is one side effect of this change: The
779+
gzip file header contains an "OS" byte in its header. That was traditionally
780+
always set to a value of 255 representing "unknown" by the :mod:`gzip`
781+
module. Now, when using :func:`~gzip.compress` with **mtime=0**, it may be
782+
set to a different value by the underlying zlib C library Python was linked
783+
against.
784+
(See :gh:`112346` for details on the side effect.)
785+
771786
.. _whatsnew311-hashlib:
772787

773788
hashlib

0 commit comments

Comments
 (0)