]> git.ipfire.org Git - thirdparty/Python/cpython.git/commitdiff
[3.12] gh-112346: Document the OS byte in `gzip.compress` output change in 3.11 ...
authorMiss Islington (bot) <31488909+miss-islington@users.noreply.github.com>
Mon, 17 Jun 2024 05:54:33 +0000 (07:54 +0200)
committerGitHub <noreply@github.com>
Mon, 17 Jun 2024 05:54:33 +0000 (05:54 +0000)
gh-112346: Document the OS byte in `gzip.compress` output change in 3.11 (GH-120480)
(cherry picked from commit bac4edad69bb20dd9460766e062637cae999e1e0)

gh-112346: Describe the "os" byte in gzip output change.

Co-authored-by: Gregory P. Smith <greg@krypto.org>
Doc/library/gzip.rst
Doc/whatsnew/3.11.rst

index a2fff0f9fcb3e50ba95d54d5624821d64d2483d4..3008866671608a17ed8dc6e1f2def4a0c22138a5 100644 (file)
@@ -194,7 +194,9 @@ The module defines the following items:
    .. versionchanged:: 3.11
       Speed is improved by compressing all data at once instead of in a
       streamed fashion. Calls with *mtime* set to ``0`` are delegated to
-      :func:`zlib.compress` for better speed.
+      :func:`zlib.compress` for better speed. In this situation the
+      output may contain a gzip header "OS" byte value other than 255
+      "unknown" as supplied by the underlying zlib implementation.
 
 .. function:: decompress(data)
 
index 5e272478ce83eea6625e31d9a5d3ff89513de39a..cbd5bb23b892542e3b684f6f1613571d31749bf2 100644 (file)
@@ -768,6 +768,21 @@ functools
   (Contributed by Yurii Karabas in :issue:`46014`.)
 
 
+.. _whatsnew311-gzip:
+
+gzip
+----
+
+* The :func:`gzip.compress` function is now faster when used with the
+  **mtime=0** argument as it delegates the compression entirely to a single
+  :func:`zlib.compress` operation. There is one side effect of this change: The
+  gzip file header contains an "OS" byte in its header. That was traditionally
+  always set to a value of 255 representing "unknown" by the :mod:`gzip`
+  module. Now, when using :func:`~gzip.compress` with **mtime=0**, it may be
+  set to a different value by the underlying zlib C library Python was linked
+  against.
+  (See :gh:`112346` for details on the side effect.)
+
 .. _whatsnew311-hashlib:
 
 hashlib