summaryrefslogtreecommitdiffstats
path: root/Lib/tarfile.py
Commit message (Collapse)AuthorAgeFilesLines
* Issue #5689: Add support for lzma compression to the tarfile module.Lars Gustäbel2011-12-101-6/+60
|
* Remove no longer needed work-around for bz2 file object support.Lars Gustäbel2011-12-061-64/+2
|
* Merge with 3.2: Correctly detect bzip2 compressed streams with blocksizes ↵Lars Gustäbel2011-12-061-1/+1
|\ | | | | | | other than 900k.
| * Correctly detect bzip2 compressed streams with blocksizes other than 900k.Lars Gustäbel2011-12-061-1/+1
| |
* | Simplify and remove few dependencies on 'errno', thanks to PEP 3151.Florent Xicluna2011-10-281-4/+2
| |
* | Merge with 3.2: Issue #13158: Fix decoding and encoding of base-256 number ↵Lars Gustäbel2011-10-141-20/+23
|\ \ | |/ | | | | | | | | | | | | fields in tarfile. The nti() function that converts a number field from a tar header to a number failed to decode GNU tar specific base-256 fields. I also added support for decoding and encoding negative base-256 number fields.
| * Issue #13158: Fix decoding and encoding of base-256 number fields in tarfile.Lars Gustäbel2011-10-141-20/+23
| | | | | | | | | | | | The nti() function that converts a number field from a tar header to a number failed to decode GNU tar specific base-256 fields. I also added support for decoding and encoding negative base-256 number fields.
* | Merge with 3.2: Issue #12841: Fix tarfile extraction of non-existent uids/gids.Lars Gustäbel2011-09-051-8/+2
|\ \ | |/
| * 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)
* | Merge with 3.2.Georg Brandl2011-08-131-2/+4
|\ \ | |/
| * Fix #11513: wrong exception handling for the case that GzipFile itself ↵Georg Brandl2011-08-131-2/+4
| | | | | | | | raises an IOError.
* | merge from 3.2 - Fix closes Issue11439 Remove the SVN keywords from the code ↵Senthil Kumaran2011-07-281-2/+2
|\ \ | |/ | | | | as it is no longer applicable in hg. Patch Contributed by Neil Muller.
| * Fix closes Issue11439 Remove the SVN keywords from the code as it is no ↵Senthil Kumaran2011-07-281-2/+2
| | | | | | | | longer applicable in hg. Patch Contributed by Neil Muller.
| * Merged revisions 88528 via svnmerge fromLars Gustäbel2011-02-231-3/+2
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | svn+ssh://pythondev@svn.python.org/python/branches/py3k ........ r88528 | lars.gustaebel | 2011-02-23 12:42:22 +0100 (Wed, 23 Feb 2011) | 16 lines Issue #11224: Improved sparse file read support (r85916) introduced a regression in _FileInFile which is used in file-like objects returned by TarFile.extractfile(). The inefficient design of the _FileInFile.read() method causes various dramatic side-effects and errors: - The data segment of a file member is read completely into memory every(!) time a small block is accessed. This is not only slow but may cause unexpected MemoryErrors with very large files. - Reading members from compressed tar archives is even slower because of the excessive backwards seeking which is done when the same data segment is read over and over again. - As a backwards seek on a TarFile opened in stream mode is not possible, using extractfile() fails with a StreamError. ........
* | remove __version__s dependent on subversion keyword expansion (closes #12221)Benjamin Peterson2011-06-011-2/+0
| |
* | Normalize the encoding names for Latin-1 and UTF-8 toMarc-André Lemburg2011-02-251-9/+9
| | | | | | | | | | | | | | | | | | | | 'latin-1' and 'utf-8'. These are optimized in the Python Unicode implementation to result in more direct processing, bypassing the codec registry. Also see issue11303.
* | Issue #11224: Improved sparse file read support (r85916) introduced aLars Gustäbel2011-02-231-3/+2
|/ | | | | | | | | | | | | | | | regression in _FileInFile which is used in file-like objects returned by TarFile.extractfile(). The inefficient design of the _FileInFile.read() method causes various dramatic side-effects and errors: - The data segment of a file member is read completely into memory every(!) time a small block is accessed. This is not only slow but may cause unexpected MemoryErrors with very large files. - Reading members from compressed tar archives is even slower because of the excessive backwards seeking which is done when the same data segment is read over and over again. - As a backwards seek on a TarFile opened in stream mode is not possible, using extractfile() fails with a StreamError.
* Issue #11014: Make 'filter' argument in tarfile.Tarfile.add() into aRaymond Hettinger2011-01-261-2/+2
| | | | | | | keyword-only argument. The preceding positional argument was deprecated, so it made no sense to add filter as a positional argument. (Patch reviewed by Brian Curtin and Anthony Long.)
* Issue #10184: Touch directories only once when extracting a tarfile.Martin v. Löwis2010-11-011-9/+13
|
* Issue #10233: Close file objects in a timely manner in the tarfile moduleAntoine Pitrou2010-10-291-9/+7
| | | | and its test suite.
* Add read support for all missing variants of the GNU sparseLars Gustäbel2010-10-291-119/+112
| | | | | | | | extensions. Thus, in addition to GNUTYPE_SPARSE headers, sparse information in pax headers created by GNU tar can now be decoded. All three formats 0.0, 0.1 and 1.0 are supported. On filesystems that support this, holes in files are now restored whenever a sparse member is extracted.
* Issue #9065: no longer use "root" as the default for theLars Gustäbel2010-10-041-4/+4
| | | | | | | | | | | | | | 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.
* Fix a line that got hacked up by r82659.Brian Curtin2010-09-241-1/+2
|
* Further tarfile / test_tarfile cleanupAntoine Pitrou2010-09-231-24/+33
|
* Try to fix test_tarfile issues on Windows buildbots by closing fileAntoine Pitrou2010-09-231-1/+7
| | | | objects explicitly instead of letting them linger on.
* Fix the breakage of Lib/tarfile.py on non-Windows platforms due toBrian Curtin2010-07-091-6/+14
| | | | | | | | | using WindowsError in a try/except. Only add WindowsError to the list of exceptions to catch when we are actually running on Windows. Additionally, add a call that was left out in test_posixpath. Thanks Amaury, Antoine, and Jason.
* Implement #1578269. Patch by Jason R. Coombs.Brian Curtin2010-07-081-2/+10
| | | | | | | | | | | | | | | | Added Windows support for os.symlink when run on Windows 6.0 or greater, aka Vista. Previous Windows versions will raise NotImplementedError when trying to symlink. Includes numerous test updates and additions to test_os, including a symlink_support module because of the fact that privilege escalation is required in order to run the tests to ensure that the user is able to create symlinks. By default, accounts do not have the required privilege, so the escalation code will have to be exposed later (or documented on how to do so). I'll be following up with that work next. Note that the tests use ctypes, which was agreed on during the PyCon language summit.
* Issue #8784: Set tarfile default encoding to 'utf-8' on Windows.Victor Stinner2010-06-111-3/+4
| | | | Note: file system encoding cannot be None anymore (since r81190, issue #8610).
* Merged revisions 81667 via svnmerge fromLars Gustäbel2010-06-031-26/+45
| | | | | | | | | | | | | | | svn+ssh://pythondev@svn.python.org/python/trunk ........ r81667 | lars.gustaebel | 2010-06-03 14:34:14 +0200 (Thu, 03 Jun 2010) | 8 lines Issue #8741: Fixed the TarFile.makelink() method that is responsible 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. ........
* Merged revisions 81663 via svnmerge fromLars Gustäbel2010-06-031-1/+1
| | | | | | | | | | | | svn+ssh://pythondev@svn.python.org/python/trunk ........ r81663 | lars.gustaebel | 2010-06-03 11:56:22 +0200 (Thu, 03 Jun 2010) | 4 lines Issue #8833: tarfile created hard link entries with a size field != 0 by mistake. The associated testcase did not expose this bug because it was broken too. ........
* Issue #8633: Support for POSIX.1-2008 binary pax headers.Lars Gustäbel2010-05-171-10/+72
| | | | | | | | | | | | | | tarfile is now able to read and write pax headers with a "hdrcharset=BINARY" record. This record was introduced in POSIX.1-2008 as a method to store unencoded binary strings that cannot be translated to UTF-8. In practice, this is just a workaround that allows a tar implementation to store filenames that do not comply with the current filesystem encoding and thus cannot be decoded correctly. Additionally, tarfile works around a bug in current versions of GNU tar: undecodable filenames are stored as-is in a pax header without a "hdrcharset" record being added. Technically, these headers are invalid, but tarfile manages to read them correctly anyway.
* Issue #8390: tarfile uses surrogateespace as the default error handlerVictor Stinner2010-05-051-9/+3
| | | | (instead of replace in read mode or strict in write mode)
* Remove traces of MacOS9 support.Ronald Oussoren2010-05-051-7/+0
| | | | Fix for issue #7908
* Merged revisions 80616 via svnmerge fromLars Gustäbel2010-04-291-1/+1
| | | | | | | | | | | svn+ssh://pythondev@svn.python.org/python/trunk ........ r80616 | lars.gustaebel | 2010-04-29 17:23:38 +0200 (Thu, 29 Apr 2010) | 4 lines Issue #8464: tarfile.open(name, mode="w|") no longer creates files with execute permissions set. ........
* convert shebang lines: python -> python3Benjamin Peterson2010-03-111-1/+1
|
* Merged revisions 78623 via svnmerge fromLars Gustäbel2010-03-031-0/+14
| | | | | | | | | | | svn+ssh://pythondev@svn.python.org/python/trunk ........ r78623 | lars.gustaebel | 2010-03-03 12:55:48 +0100 (Wed, 03 Mar 2010) | 3 lines Issue #7232: Add support for the context manager protocol to the TarFile class. ........
* Issue #4757: `zlib.compress` and other methods in the zlib module nowAntoine Pitrou2009-12-141-1/+1
| | | | | raise a TypeError when given an `str` object (rather than a `bytes`-like object). Patch by Victor Stinner and Florent Xicluna.
* Merged revisions 76780 via svnmerge fromLars Gustäbel2009-12-131-1/+1
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | svn+ssh://pythondev@svn.python.org/python/trunk ........ r76780 | lars.gustaebel | 2009-12-13 12:32:27 +0100 (Sun, 13 Dec 2009) | 21 lines Issue #7357: No longer suppress fatal extraction errors by 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. ........
* Merged revisions 76443 via svnmerge fromLars Gustäbel2009-11-221-27/+60
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | svn+ssh://pythondev@svn.python.org/python/trunk ........ r76443 | lars.gustaebel | 2009-11-22 19:30:53 +0100 (Sun, 22 Nov 2009) | 24 lines Issue #6123: Fix opening empty archives and files. (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. ........
* Merged revisions 76381 via svnmerge fromLars Gustäbel2009-11-181-21/+27
| | | | | | | | | | | svn+ssh://pythondev@svn.python.org/python/trunk ........ r76381 | lars.gustaebel | 2009-11-18 21:24:54 +0100 (Wed, 18 Nov 2009) | 3 lines Issue #7341: Close the internal file object in the TarFile constructor in case of an error. ........
* Merged revisions 74750 via svnmerge fromLars Gustäbel2009-09-121-6/+21
| | | | | | | | | | | | | | | | | svn+ssh://pythondev@svn.python.org/python/trunk ........ r74750 | lars.gustaebel | 2009-09-12 12:28:15 +0200 (Sat, 12 Sep 2009) | 9 lines Issue #6856: Add a filter keyword argument to TarFile.add(). 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. ........
* Merged revisions 74571 via svnmerge fromLars Gustäbel2009-08-281-29/+12
| | | | | | | | | | | | | | svn+ssh://pythondev@svn.python.org/python/trunk ........ r74571 | lars.gustaebel | 2009-08-28 21:23:44 +0200 (Fri, 28 Aug 2009) | 7 lines Issue #6054: Do not normalize stored pathnames. No longer use tarfile.normpath() on pathnames. Store pathnames unchanged, i.e. do not remove "./", "../" and "//" occurrences. However, still convert absolute to relative paths. ........
* Merged revisions 70523 via svnmerge fromLars Gustäbel2009-03-221-5/+4
| | | | | | | | | | | | | svn+ssh://pythondev@svn.python.org/python/trunk ........ r70523 | lars.gustaebel | 2009-03-22 21:09:33 +0100 (Sun, 22 Mar 2009) | 5 lines Issue #5068: Fixed the tarfile._BZ2Proxy.read() method that would loop 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. ........
* Merged revisions 69846 via svnmerge fromMark Dickinson2009-02-211-1/+1
| | | | | | | | | | svn+ssh://pythondev@svn.python.org/python/trunk ........ r69846 | mark.dickinson | 2009-02-21 20:27:01 +0000 (Sat, 21 Feb 2009) | 2 lines Issue #5341: Fix a variety of spelling errors. ........
* Merged revisions 67717 via svnmerge fromLars Gustäbel2008-12-121-4/+0
| | | | | | | | | | svn+ssh://pythondev@svn.python.org/python/trunk ........ r67717 | lars.gustaebel | 2008-12-12 14:58:03 +0100 (Fri, 12 Dec 2008) | 2 lines Issue #4616: TarFile.utime(): Restore directory times on Windows. ........
* #2834: Change re module semantics, so that str and bytes mixing is forbidden,Antoine Pitrou2008-08-191-1/+1
| | | | | and str (unicode) patterns get full unicode matching by default. The re.ASCII flag is also introduced to ask for ASCII matching instead.
* Remove the deprecated posix attribute.Georg Brandl2008-08-041-11/+0
|
* Remove the TarFileCompat class from tarfile.py.Lars Gustäbel2008-08-021-48/+0
|
* Merged revisions ↵Georg Brandl2008-06-101-1/+0
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | 63724,63726,63732,63744,63754-63755,63757-63758,63760,63775,63781-63782,63787,63805-63808,63818-63819,63823-63824 via svnmerge from svn+ssh://pythondev@svn.python.org/python/trunk ........ r63724 | gregory.p.smith | 2008-05-26 22:22:14 +0200 (Mon, 26 May 2008) | 6 lines Fixes issue2791: subprocess.Popen.communicate leaked a file descripton until the last reference to the Popen instance was dropped. Adding explicit close() calls fixes it. Candidate for backport to release25-maint. ........ r63726 | benjamin.peterson | 2008-05-26 22:43:24 +0200 (Mon, 26 May 2008) | 2 lines fix minor grammar typo ........ r63732 | benjamin.peterson | 2008-05-26 23:44:26 +0200 (Mon, 26 May 2008) | 2 lines remove duplication in test module ........ r63744 | lars.gustaebel | 2008-05-27 14:39:23 +0200 (Tue, 27 May 2008) | 3 lines Do not close external file objects passed to tarfile.open(mode='w:bz2') when the TarFile is closed. ........ r63754 | benjamin.peterson | 2008-05-28 03:12:35 +0200 (Wed, 28 May 2008) | 2 lines update tutorial function with more appropiate one from Eric Smith ........ r63755 | mark.hammond | 2008-05-28 03:54:55 +0200 (Wed, 28 May 2008) | 2 lines bdist_wininst now works correctly when both --skip-build and --plat-name are specified. ........ r63757 | georg.brandl | 2008-05-28 13:21:39 +0200 (Wed, 28 May 2008) | 2 lines #2989: add PyType_Modified(). ........ r63758 | benjamin.peterson | 2008-05-28 13:51:41 +0200 (Wed, 28 May 2008) | 2 lines fix spelling ........ r63760 | georg.brandl | 2008-05-28 17:41:36 +0200 (Wed, 28 May 2008) | 2 lines #2990: prevent inconsistent state while updating method cache. ........ r63775 | georg.brandl | 2008-05-29 09:18:17 +0200 (Thu, 29 May 2008) | 2 lines Two fixes in bytearray docs. ........ r63781 | georg.brandl | 2008-05-29 09:38:37 +0200 (Thu, 29 May 2008) | 2 lines #2988: add note about catching CookieError when parsing untrusted cookie data. ........ r63782 | georg.brandl | 2008-05-29 09:45:26 +0200 (Thu, 29 May 2008) | 2 lines #2985: allow i8 in XMLRPC responses. ........ r63787 | georg.brandl | 2008-05-29 16:35:39 +0200 (Thu, 29 May 2008) | 2 lines Revert #2990 patch; it's not necessary as Armin showed. ........ r63805 | raymond.hettinger | 2008-05-30 08:37:27 +0200 (Fri, 30 May 2008) | 1 line Issue 2784: fix leaks in exception exit. ........ r63806 | raymond.hettinger | 2008-05-30 08:49:47 +0200 (Fri, 30 May 2008) | 1 line Issue 2855: Fix obscure crasher by slowing down the entire module. Mimics what was done to dictionaries in r59223. ........ r63807 | raymond.hettinger | 2008-05-30 09:16:53 +0200 (Fri, 30 May 2008) | 1 line Issue 2903: Add __name__ in globals for namedtuple namespace. ........ r63808 | georg.brandl | 2008-05-30 09:54:16 +0200 (Fri, 30 May 2008) | 2 lines #2999: fix name of third parameter in unicode.replace()'s docstring. ........ r63818 | georg.brandl | 2008-05-30 21:12:13 +0200 (Fri, 30 May 2008) | 2 lines getloadavg() is not available on Windows. ........ r63819 | georg.brandl | 2008-05-30 21:17:29 +0200 (Fri, 30 May 2008) | 2 lines Better quote with single quotes. ........ r63823 | benjamin.peterson | 2008-05-30 22:44:39 +0200 (Fri, 30 May 2008) | 2 lines fix grammar ........ r63824 | marc-andre.lemburg | 2008-05-30 22:52:18 +0200 (Fri, 30 May 2008) | 5 lines Update the locale module alias table. Closes #3011. ........
* Issue #2058: Remove the buf attribute and add __slots__ to theLars Gustäbel2008-04-141-34/+43
| | | | TarInfo class in order to reduce tarfile's memory usage.