cpython: 9d5217aaea13 (original) (raw)

Mercurial > cpython

changeset 100273:9d5217aaea13 2.7

Issues #22468, #21996, #22208: Clarify gettarinfo() and TarInfo usage * Make it more obvious gettarinfo() is based on stat(), and that non-ordinary files may need special care * Filename taken from fileobj.name; suggest dummy arcname as a workaround * Indicate TarInfo may be used directly, not just via gettarinfo() [#22468]

Martin Panter vadmium+py@gmail.com
date Fri, 19 Feb 2016 23:34:56 +0000
parents 2d8e8d0e7162
children ada8023878d0
files Doc/library/tarfile.rst Lib/tarfile.py
diffstat 2 files changed, 23 insertions(+), 13 deletions(-)[+] [-] Doc/library/tarfile.rst 21 Lib/tarfile.py 15

line wrap: on

line diff

--- a/Doc/library/tarfile.rst +++ b/Doc/library/tarfile.rst @@ -438,20 +438,29 @@ be finalized; only the internally used f Add the :class:TarInfo object tarinfo to the archive. If fileobj is given, tarinfo.size bytes are read from it and added to the archive. You can

.. method:: TarFile.gettarinfo(name=None, arcname=None, fileobj=None)

.. method:: TarFile.close()

--- a/Lib/tarfile.py +++ b/Lib/tarfile.py @@ -1844,11 +1844,12 @@ class TarFile(object): return [tarinfo.name for tarinfo in self.getmembers()] def gettarinfo(self, name=None, arcname=None, fileobj=None):

@@ -1869,7 +1870,7 @@ class TarFile(object): # Now, fill the TarInfo object with # information specific for the file. tarinfo = self.tarinfo()

# Use os.stat or os.lstat, depending on platform # and if symlinks shall be resolved. @@ -2034,7 +2035,7 @@ class TarFile(object): def addfile(self, tarinfo, fileobj=None): """Add the TarInfo object tarinfo' to the archive. If fileobj' is given, tarinfo.size bytes are read from it and added to the archive.