From b733cd006ed4f36083cd33db72973dd79eaadc0c Mon Sep 17 00:00:00 2001 From: slateny <46876382+slateny@users.noreply.github.com> Date: Mon, 28 Feb 2022 00:26:09 -0800 Subject: [PATCH 1/2] Update tarfile.rst --- Doc/library/tarfile.rst | 4 ++-- Lib/tarfile.py | 9 +++++---- 2 files changed, 7 insertions(+), 6 deletions(-) diff --git a/Doc/library/tarfile.rst b/Doc/library/tarfile.rst index f5c49b0ac4f738..d4b3c5c523f2ac 100644 --- a/Doc/library/tarfile.rst +++ b/Doc/library/tarfile.rst @@ -111,8 +111,8 @@ Some facts and figures: be done on the file. If given, *fileobj* may be any object that has a :meth:`read` or :meth:`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 + 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: diff --git a/Lib/tarfile.py b/Lib/tarfile.py index 8d43d0da7b9880..bc15c484ad06e4 100755 --- a/Lib/tarfile.py +++ b/Lib/tarfile.py @@ -328,10 +328,11 @@ def write(self, s): 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. """ From e541a872d1ac40d595fbc73f7d2d12de8df5df0b Mon Sep 17 00:00:00 2001 From: Serhiy Storchaka Date: Wed, 27 Dec 2023 18:57:39 +0200 Subject: [PATCH 2/2] Fix references to read() and write() methods. --- Doc/library/tarfile.rst | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) diff --git a/Doc/library/tarfile.rst b/Doc/library/tarfile.rst index af8d2924194f69..7ba29d4a40dedb 100644 --- a/Doc/library/tarfile.rst +++ b/Doc/library/tarfile.rst @@ -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.buffer``, 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: