]> git.ipfire.org Git - thirdparty/Python/cpython.git/commitdiff
[3.12] gh-67641: Clarify documentation on bytes vs text with non-seeking tarfile...
authorMiss Islington (bot) <31488909+miss-islington@users.noreply.github.com>
Wed, 27 Dec 2023 17:32:10 +0000 (18:32 +0100)
committerGitHub <noreply@github.com>
Wed, 27 Dec 2023 17:32:10 +0000 (17:32 +0000)
(cherry picked from commit 0651936ae2bc6999f488f8c519b8d07a06a11557)

Co-authored-by: Stanley <46876382+slateny@users.noreply.github.com>
Doc/library/tarfile.rst
Lib/tarfile.py

index 7078fc04bfd0ee52749c4303de306085d04f429a..6e34158084eb5cab2ad4673a86baaea1dc95da2b 100644 (file)
@@ -116,10 +116,12 @@ Some facts and figures:
    ``'filemode|[compression]'``.  :func:`tarfile.open` will return a :class:`TarFile`
    object that processes its data as a stream of blocks.  No random seeking will
    be done on the file. If given, *fileobj* may be any object that has a
-   :meth:`~io.TextIOBase.read` or :meth:`~io.TextIOBase.write` method (depending on the *mode*). *bufsize*
-   specifies the blocksize and defaults to ``20 * 512`` bytes. Use this variant
-   in combination with e.g. ``sys.stdin``, a socket :term:`file object` or a tape
-   device. However, such a :class:`TarFile` object is limited in that it does
+   :meth:`~io.RawIOBase.read` or :meth:`~io.RawIOBase.write` method
+   (depending on the *mode*) that works with bytes.
+   *bufsize* specifies the blocksize and defaults to ``20 * 512`` bytes.
+   Use this variant in combination with e.g. ``sys.stdin.buffer``, a socket
+   :term:`file object` or a tape device.
+   However, such a :class:`TarFile` object is limited in that it does
    not allow random access, see :ref:`tar-examples`.  The currently
    possible modes:
 
index 02f5e3b66c0766296baf63884ff5b5798565e94f..027a19b9ed5994651841b930e1e0c85e9b6f8c9a 100755 (executable)
@@ -331,10 +331,11 @@ class _LowLevelFile:
 class _Stream:
     """Class that serves as an adapter between TarFile and
        a stream-like object.  The stream-like object only
-       needs to have a read() or write() method and is accessed
-       blockwise.  Use of gzip or bzip2 compression is possible.
-       A stream-like object could be for example: sys.stdin,
-       sys.stdout, a socket, a tape device etc.
+       needs to have a read() or write() method that works with bytes,
+       and the method is accessed blockwise.
+       Use of gzip or bzip2 compression is possible.
+       A stream-like object could be for example: sys.stdin.buffer,
+       sys.stdout.buffer, a socket, a tape device etc.
 
        _Stream is intended to be used only internally.
     """