summaryrefslogtreecommitdiffstats
path: root/Doc
diff options
context:
space:
mode:
authorlyc8503 <me@lyc8503.site>2024-04-19 11:41:51 (GMT)
committerGitHub <noreply@github.com>2024-04-19 11:41:51 (GMT)
commit15b3555e4a47ec925c965778a415dc11f0f981fd (patch)
tree9699f4644620c576afa6d727c776b3ac09b608f9 /Doc
parent3e7d990a09f0928050b2b0c85f724c2bce13fcbb (diff)
downloadcpython-15b3555e4a47ec925c965778a415dc11f0f981fd.zip
cpython-15b3555e4a47ec925c965778a415dc11f0f981fd.tar.gz
cpython-15b3555e4a47ec925c965778a415dc11f0f981fd.tar.bz2
gh-116931: Add fileobj parameter check for Tarfile.addfile (GH-117988)
Tarfile.addfile now throws an ValueError when the user passes in a non-zero size tarinfo but does not provide a fileobj, instead of writing an incomplete entry.
Diffstat (limited to 'Doc')
-rw-r--r--Doc/library/tarfile.rst10
1 files changed, 7 insertions, 3 deletions
diff --git a/Doc/library/tarfile.rst b/Doc/library/tarfile.rst
index 2134293a..afcad9b 100644
--- a/Doc/library/tarfile.rst
+++ b/Doc/library/tarfile.rst
@@ -637,11 +637,15 @@ be finalized; only the internally used file object will be closed. See the
.. method:: TarFile.addfile(tarinfo, fileobj=None)
- Add the :class:`TarInfo` object *tarinfo* to the archive. If *fileobj* is given,
- it should be a :term:`binary file`, and
- ``tarinfo.size`` bytes are read from it and added to the archive. You can
+ Add the :class:`TarInfo` object *tarinfo* to the archive. If *tarinfo* represents
+ a non zero-size regular file, the *fileobj* argument should be a :term:`binary file`,
+ and ``tarinfo.size`` bytes are read from it and added to the archive. You can
create :class:`TarInfo` objects directly, or by using :meth:`gettarinfo`.
+ .. versionchanged:: 3.13
+
+ *fileobj* must be given for non-zero-sized regular files.
+
.. method:: TarFile.gettarinfo(name=None, arcname=None, fileobj=None)