summaryrefslogtreecommitdiff
path: root/Lib/tarfile.py
Commit message (Collapse)AuthorAgeFilesLines
* Fix closes issue #12088 - fixes the tarfile.extractall issue when theSenthil Kumaran2011-05-171-1/+3
| | | | | symlinks/hardlink was broken. It handles now in a graceful manner (No exception is raised, behavior similar GNU tar).
* Fix closes issue10761: tarfile.extractall failure when symlinked files are ↵Senthil Kumaran2011-04-281-0/+2
| | | | present.
* Merged revisions 85211 via svnmerge fromLars Gustäbel2010-10-041-4/+4
| | | | | | | | | | | | | | | | | | | | | svn+ssh://pythondev@svn.python.org/python/branches/py3k ........ r85211 | lars.gustaebel | 2010-10-04 17:18:47 +0200 (Mon, 04 Oct 2010) | 14 lines Issue #9065: no longer use "root" as the default for the uname and gname field. If tarfile creates a new archive and adds a file with a uid/gid that doesn't have a corresponding name on the system (e.g. because the user/group account was deleted) it uses the empty string in the uname/gname field now instead of "root". Using "root" as the default was a bad idea because on extraction the uname/gname fields are supposed to override the uid/gid fields. So, all archive members with nameless uids/gids belonged to the root user after extraction. ........
* Issue #8741: Fixed the TarFile.makelink() method that is responsibleLars Gustäbel2010-06-031-26/+45
| | | | | | | | for extracting symbolic and hard link entries as regular files as a work-around on platforms that do not support filesystem links. This stopped working reliably after a change in r74571. I also added a few tests for this functionality.
* Issue #8833: tarfile created hard link entries with a sizeLars Gustäbel2010-06-031-1/+1
| | | | | field != 0 by mistake. The associated testcase did not expose this bug because it was broken too.
* In a number of places code still reversRonald Oussoren2010-05-051-7/+0
| | | | | | | | | to "sys.platform == 'mac'" and that is dead code because it refers to a platform that is no longer supported (and hasn't been supported for several releases). Fixes issue #7908 for the trunk.
* Issue #8464: tarfile.open(name, mode="w|") no longer createsLars Gustäbel2010-04-291-1/+1
| | | | files with execute permissions set.
* Issue #7232: Add support for the context manager protocolLars Gustäbel2010-03-031-0/+14
| | | | to the TarFile class.
* Issue #7357: No longer suppress fatal extraction errors byLars Gustäbel2009-12-131-1/+1
| | | | | | | | | | | | | | | | | | | | | | default. TarFile's errorlevel argument controls how errors are handled that occur during extraction. There are three possible levels 0, 1 and 2. If errorlevel is set to 1 or 2 fatal errors (e.g. a full filesystem) are raised as exceptions. If it is set to 0, which is the default value, extraction errors are suppressed, and error messages are written to the debug log instead. But, if the debug log is not activated, which is the default as well, all these errors go unnoticed. The original intention was to imitate GNU tar which tries to extract as many members as possible instead of stopping on the first error. It turns out that this is no good default behaviour for a tar library. This patch simply changes the default value for the errorlevel argument from 0 to 1, so that fatal extraction errors are raised as EnvironmentError exceptions.
* Issue #6123: Fix opening empty archives and files.Lars Gustäbel2009-11-221-27/+60
| | | | | | | | | | | | | | | | | | | | | | | (Note that an empty archive is not the same as an empty file. An empty archive contains no members and is correctly terminated with an EOF block full of zeros. An empty file contains no data at all.) The problem was that although tarfile was able to create empty archives, it failed to open them raising a ReadError. On the other hand, tarfile opened empty files without error in most read modes and presented them as empty archives. (However, some modes still raised errors: "r|gz" raised ReadError, but "r:gz" worked, "r:bz2" even raised EOFError.) In order to get a more fine-grained control over the various internal error conditions I now split up the HeaderError exception into a number of meaningful sub-exceptions. This makes it easier in the TarFile.next() method to react to the different conditions in the correct way. The visible change in its behaviour now is that tarfile will open empty archives correctly and raise ReadError consistently for empty files.
* Issue #7341: Close the internal file object in the TarFileLars Gustäbel2009-11-181-21/+27
| | | | constructor in case of an error.
* Issue #6856: Add a filter keyword argument to TarFile.add().Lars Gustäbel2009-09-121-6/+21
| | | | | | | | | The filter argument must be a function that takes a TarInfo object argument, changes it and returns it again. If the function returns None the TarInfo object will be excluded from the archive. The exclude argument is deprecated from now on, because it does something similar but is not as flexible.
* Issue #6054: Do not normalize stored pathnames.Lars Gustäbel2009-08-281-29/+12
| | | | | | No longer use tarfile.normpath() on pathnames. Store pathnames unchanged, i.e. do not remove "./", "../" and "//" occurrences. However, still convert absolute to relative paths.
* #4351: more appropriate DeprecationWarning stacklevelsPhilip Jenvey2009-05-081-1/+2
|
* Issue #5068: Fixed the tarfile._BZ2Proxy.read() method that would loopLars Gustäbel2009-03-221-5/+4
| | | | | | forever on incomplete input. That caused tarfile.open() to hang when used with mode 'r' or 'r:bz2' and a fileobj argument that contained no data or partial bzip2 compressed data.
* Issue #5341: Fix a variety of spelling errors.Mark Dickinson2009-02-211-1/+1
|
* Issue #4616: TarFile.utime(): Restore directory times on Windows.Lars Gustäbel2008-12-121-4/+0
|
* Remove a dict.has_key() and list.sort(cmp=) usage from tarfile to silenceBrett Cannon2008-08-041-2/+3
| | | | warnings under -3.
* Issue #3039: Fix TarFileCompat.writestr() which always raised anLars Gustäbel2008-08-021-4/+7
| | | | | | AttributeError since __slots__ were added to zipfile.ZipInfo in r46967 two years ago. Add a warning about the removal of TarFileCompat in Python 3.0.
* Do not close external file objects passed to tarfile.open(mode='w:bz2')Lars Gustäbel2008-05-271-1/+0
| | | | when the TarFile is closed.
* A stab in the dark attempt to fix the alpha/tru64 buildbot problem and add moreGregory P. Smith2008-03-251-2/+2
| | | | test coverage of valid inputs to zlib.crc32.
* Issue #2004: Use mode 0700 for temporary directories and defaultLars Gustäbel2008-02-051-9/+9
| | | | | | permissions for missing directories. (will backport to 2.5)
* Issue #1735: TarFile.extractall() now correctly setsLars Gustäbel2008-01-041-4/+4
| | | | | | directory permissions and times. (will backport to 2.5)
* Issue #1531: Read fileobj from the current offset, do not seek toLars Gustäbel2007-12-011-1/+2
| | | | | | the start. (will backport to 2.5)
* TarFile.__init__() no longer fails if no name argument is passed andLars Gustäbel2007-08-281-1/+1
| | | | | | the fileobj argument has no usable name attribute (e.g. StringIO). (will backport to 2.5)
* Added exclude keyword argument to the TarFile.add() method.Lars Gustäbel2007-06-181-4/+10
|
* Added errors argument to TarFile class that allows the user toLars Gustäbel2007-05-271-101/+134
| | | | | | | | | | | | | | | | | | | | specify an error handling scheme for character conversion. Additional scheme "utf-8" in read mode. Unicode input filenames are now supported by design. The values of the pax_headers dictionary are now limited to unicode objects. Fixed: The prefix field is no longer used in PAX_FORMAT (in conformance with POSIX). Fixed: In read mode use a possible pax header size field. Fixed: Strip trailing slashes from pax header name values. Fixed: Give values in user-specified pax_headers precedence when writing. Added unicode tests. Added pax/regtype4 member to testtar.tar all possible number fields in a pax header. Added two chapters to the documentation about the different formats tarfile.py supports and how unicode issues are handled.
* Remove direct call's to file's constructor and replace them with calls toBrett Cannon2007-05-251-4/+5
| | | | open() as ths is considered best practice.
* This is the implementation of POSIX.1-2001 (pax) format read/writeLars Gustäbel2007-03-131-334/+646
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | support. The TarInfo class now contains all necessary logic to process and create tar header data which has been moved there from the TarFile class. The fromtarfile() method was added. The new path and linkpath properties are aliases for the name and linkname attributes in correspondence to the pax naming scheme. The TarFile constructor and classmethods now accept a number of keyword arguments which could only be set as attributes before (e.g. dereference, ignore_zeros). The encoding and pax_headers arguments were added for pax support. There is a new tarinfo keyword argument that allows using subclassed TarInfo objects in TarFile. The boolean TarFile.posix attribute is deprecated, because now three tar formats are supported. Instead, the desired format for writing is specified using the constants USTAR_FORMAT, GNU_FORMAT and PAX_FORMAT as the format keyword argument. This change affects TarInfo.tobuf() as well. The test suite has been heavily reorganized and partially rewritten. A new testtar.tar was added that contains sample data in many formats from 4 different tar programs. Some bugs and quirks that also have been fixed: Directory names do no longer have a trailing slash in TarInfo.name or TarFile.getnames(). Adding the same file twice does not create a hardlink file member. The TarFile constructor does no longer need a name argument. The TarFile._mode attribute was renamed to mode and contains either 'r', 'w' or 'a'.
* Patch #1652681: create nonexistent files in append mode andLars Gustäbel2007-02-061-2/+7
| | | | allow appending to empty files.
* Patch #1507247: tarfile.py: use current umask for intermediateLars Gustäbel2007-01-231-13/+1
| | | | directories.
* Patch #1504073: Fix tarfile.open() for mode "r" with a fileobj argument.Lars Gustäbel2006-12-271-0/+4
| | | | Will backport to 2.5.
* Patch #1262036: Prevent TarFiles from being added to themselves underLars Gustäbel2006-12-231-27/+6
| | | | | | certain conditions. Will backport to 2.5.
* Patch #1230446: tarfile.py: fix ExFileObject so that read() and tell()Lars Gustäbel2006-12-231-106/+153
| | | | | | work correctly together with readline(). Will backport to 2.5.
* Testcase for patch #1484695.Georg Brandl2006-12-201-6/+5
|
* Patch #1484695: The tarfile module now raises a HeaderError exceptionGeorg Brandl2006-12-191-10/+17
| | | | if a buffer given to frombuf() is invalid.
* Patch #1610437: fix a tarfile bug with long filename headers.Georg Brandl2006-12-061-2/+6
|
* Patch #1583880: fix tarfile's problems with long names and posix/Georg Brandl2006-10-291-88/+81
| | | | GNU modes.
* Patch [ 1583506 ] tarfile.py: 100-char filenames are truncatedGeorg Brandl2006-10-241-1/+1
|
* Fix tarfile depending on buggy int('1\0', base) behavior.Georg Brandl2006-10-121-1/+1
|
* Fix bug #1543303, tarfile adds padding that breaks gunzip.Neal Norwitz2006-08-211-3/+0
| | | | | | Patch # 1543897. Will backport to 2.5
* _Stream.close(): Try to kill struct.pack() warnings whenTim Peters2006-08-021-1/+7
| | | | | | | | | | writing the crc to file on the "PPC64 Debian trunk" buildbot when running test_tarfile. This is again a case where the native zlib crc is an unsigned 32-bit int, but the Python wrapper implicitly casts it to signed C long, so that "the sign bit looks different" on different platforms.
* Part of SF patch #1484695. This removes dead code. The chksum wasNeal Norwitz2006-07-101-7/+0
| | | | | | already verified in .frombuf() on the lines above. If there was a problem an exception is raised, so there was no way this condition could have been true.
* Always close BZ2Proxy object. Remove unnecessary struct usage.Georg Brandl2006-05-271-13/+10
|
* Whitespace normalization.Tim Peters2006-05-191-1/+1
|
* Amendments to patch #1484695.Georg Brandl2006-05-181-45/+52
|
* [ 1488881 ] tarfile.py: support for file-objects and bz2 (cp. #1488634)Georg Brandl2006-05-151-2/+67
|
* Patch #1484695: Update the tarfile module to version 0.8. This fixesGeorg Brandl2006-05-101-180/+200
| | | | | a couple of issues, notably handling of long file names using the GNU LONGNAME extension.
* Patch #1338314, Bug #1336623: fix tarfile so it can extractNeal Norwitz2005-10-281-5/+6
| | | | | | REGTYPE directories from tarfiles written by old programs. Will backport.
* Fix SF bug # 1330039, patch # 1331635 from Lars Gustaebel (tarfile maintainer)Neal Norwitz2005-10-201-1/+2
| | | | | | | | | | | | | | Problem: if two files are assigned the same inode number by the filesystem, the second one will be added as a hardlink to the first, which means that the content will be lost. The patched code checks if the file's st_nlink is greater 1. So only for files that actually have several links pointing to them hardlinks will be created, which is what GNU tar does. Will backport.