summaryrefslogtreecommitdiffstats
path: root/Lib/tarfile.py
Commit message (Collapse)AuthorAgeFilesLines
* properly handle file closing in error cases (closes #22266)Benjamin Peterson2014-08-281-29/+48
|
* Backout 308f3c1e36d3. This change (issue21044) does not need to be merged onSerhiy Storchaka2014-07-221-2/+1
| | | | 2.7, as the os.fdopen sets the name attribute to '<fdopen>' and not to the fd.
* Issue 21044: tarfile.open() now handles fileobj with an integer 'name'Serhiy Storchaka2014-07-161-1/+2
| | | | attribute. Based on patch by Martin Panter.
* Issue #20243: TarFile no longer raise ReadError when opened in write mode.Serhiy Storchaka2014-01-181-2/+6
|
* Issue #20245: The open functions in the tarfile module now correctly handle ↵Serhiy Storchaka2014-01-181-7/+8
| | | | empty mode.
* Issue #19936: Added executable bits or shebang lines to Python scripts whichSerhiy Storchaka2014-01-161-1/+0
| | | | | | requires them. Disable executable bits and shebang lines in test and benchmark files in order to prevent using a random system python, and in source files of modules which don't provide command line interface.
* #18705: fix a number of typos. Patch by Févry Thibault.Ezio Melotti2013-08-171-1/+1
|
* Issue #16601: Restarting iteration over tarfile no more continues from whereSerhiy Storchaka2013-05-091-5/+7
| | | | it left off. Patch by Michael Birtwell.
* Issue #16477: Close tarfile internal handlers in case of exception.Andrew Svetlov2012-11-291-7/+7
| | | | Patch by Serhiy Storchaka.
* Issue #14160: TarFile.extractfile() failed to resolve symbolic links whenLars Gustäbel2012-04-241-1/+1
| | | | the links were not located in an archive subdirectory.
* Issue #13639: Accept unicode filenames in tarfile.open(mode="w|gz").Lars Gustäbel2011-12-211-0/+2
| | | | | | Passing a unicode filename to tarfile.open() along with mode "w|gz" failed with a UnicodeError because the filename was not encoded properly before being written to the gzipped stream in the FNAME extra field.
* Correctly detect bzip2 compressed streams with blocksizes other than 900k.Lars Gustäbel2011-12-061-1/+1
|
* Issue #12841: Fix tarfile extraction of non-existent uids/gids.Lars Gustäbel2011-09-051-8/+2
| | | | | | | tarfile unnecessarily checked the existence of numerical user and group ids on extraction. If one of them did not exist the respective id of the current user (i.e. root) was used for the file and ownership information was lost. (Patch by Sebastien Luttringer)
* Fix closes Issue11439 - Handle the SVN Keywords in 2.7 by replacing them ↵Senthil Kumaran2011-07-281-1/+1
| | | | with a high number so that code relying on them does not break.
* 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.