Commit Graph

228 Commits

Author SHA1 Message Date
Serhiy Storchaka 67e1aa0b58 Issue #29094: Offsets in a ZIP file created with extern file object and modes
"w" and "x" now are relative to the start of the file.
2017-01-02 01:43:02 +02:00
Serhiy Storchaka e465a9af8e Issue #29094: Offsets in a ZIP file created with extern file object and modes
"w" and "x" now are relative to the start of the file.
2017-01-01 19:05:29 +02:00
Serhiy Storchaka 34cba33403 Issue #29094: Offsets in a ZIP file created with extern file object and modes
"w" and "x" now are relative to the start of the file.
2017-01-01 19:00:30 +02:00
Serhiy Storchaka 70d28a184c Remove unused imports. 2016-12-16 20:00:15 +02:00
Serhiy Storchaka 8c9331057d Issue #28115: Command-line interface of the zipfile module now uses argparse.
Added support of long options.
2016-10-23 13:32:12 +03:00
Serhiy Storchaka f068415c51 Issue #26293: Fixed writing ZIP files that starts not from the start of the
file.  Offsets in ZIP file now are relative to the start of the archive in
conforming to the specification.
2016-10-07 22:25:05 +03:00
Serhiy Storchaka 242c170f87 Issue #26293: Fixed writing ZIP files that starts not from the start of the
file.  Offsets in ZIP file now are relative to the start of the archive in
conforming to the specification.
2016-10-07 22:24:20 +03:00
Serhiy Storchaka 8793b21525 Issue #26293: Fixed writing ZIP files that starts not from the start of the
file.  Offsets in ZIP file now are relative to the start of the archive in
conforming to the specification.
2016-10-07 22:20:50 +03:00
Serhiy Storchaka 2f76b5694d Issue #28102: The zipfile module CLI now prints usage to stderr.
Patch by Stephen J. Turnbull.
2016-09-13 09:26:29 +03:00
Serhiy Storchaka b0d497c072 Issue #24693: Changed some RuntimeError's in the zipfile module to more
appropriate types. Improved some error messages and debugging output.
2016-09-10 21:28:07 +03:00
Serhiy Storchaka e670be2273 Issue #27029: Removed deprecated support of universal newlines mode from ZipFile.open(). 2016-06-11 19:32:44 +03:00
Serhiy Storchaka f47fc5553b Issue #26039: Document ZipInfo.is_dir() and make force_zip64 keyword-only.
Patch by Thomas Kluyver.
2016-05-15 12:27:16 +03:00
Serhiy Storchaka 18ee29d0b8 Issue #26039: zipfile.ZipFile.open() can now be used to write data into a ZIP
file, as well as for extracting data.  Patch by Thomas Kluyver.
2016-05-13 13:52:49 +03:00
Serhiy Storchaka 503f908090 Issue #26039: Added zipfile.ZipInfo.from_file() and zipinfo.ZipInfo.is_dir().
Patch by Thomas Kluyver.
2016-02-08 00:02:25 +02:00
Martin Panter b82032f935 Issue #22341: Drop Python 2 workaround and document CRC initial value
Also align the parameter naming in binascii to be consistent with zlib.
2015-12-11 05:19:29 +00:00
Serhiy Storchaka 6e3d2ba269 Issue #25624: ZipFile now always writes a ZIP_STORED header for directory
entries.  Patch by Dingyuan Wang.
2015-11-22 14:50:25 +02:00
Serhiy Storchaka 8bc792a602 Issue #25624: ZipFile now always writes a ZIP_STORED header for directory
entries.  Patch by Dingyuan Wang.
2015-11-22 14:49:58 +02:00
Serhiy Storchaka 9e777730eb Issue #25364: zipfile now works in threads disabled builds. 2015-10-10 19:43:32 +03:00
Brett Cannon f299abdafa Issue #23731: Implement PEP 488.
The concept of .pyo files no longer exists. Now .pyc files have an
optional `opt-` tag which specifies if any extra optimizations beyond
the peepholer were applied.
2015-04-13 14:21:02 -04:00
Serhiy Storchaka 764fc9bfac Issue #21717: The zipfile.ZipFile.open function now supports 'x' (exclusive
creation) mode.
2015-03-25 10:09:41 +02:00
Serhiy Storchaka 77d899726f Issue #23252: Added support for writing ZIP files to unseekable streams. 2015-03-23 01:09:35 +02:00
Serhiy Storchaka 5b90f5de26 Don't seek to the start of the file when open ZipFile with the 'w' mode
(regression introduced in issue #14099).
2015-02-01 19:01:10 +02:00
Serhiy Storchaka a14f7d239f Issue #14099: Restored support of writing ZIP files to tellable but
non-seekable streams.
2015-01-26 14:01:27 +02:00
Serhiy Storchaka f15e524026 Issue #14099: Writing to ZipFile and reading multiple ZipExtFiles is
threadsafe now.
2015-01-26 13:53:38 +02:00
Serhiy Storchaka f4adbae927 Issue #14099: ZipFile.open() no longer reopen the underlying file. Objects
returned by ZipFile.open() can now operate independently of the ZipFile even
if the ZipFile was created by passing in a file-like object as the first
argument to the constructor.
2014-12-03 09:14:36 +02:00
Serhiy Storchaka 1ad088f3ea Issue #14099: ZipFile.open() no longer reopen the underlying file. Objects
returned by ZipFile.open() can now operate independently of the ZipFile even
if the ZipFile was created by passing in a file-like object as the first
argument to the constructor.
2014-12-03 09:11:57 +02:00
Serhiy Storchaka 51a43703af Issue #22217: Implemented reprs of classes in the zipfile module. 2014-10-29 22:42:06 +02:00
Serhiy Storchaka 518e71b18a Issue #22219: The zipfile module CLI now adds entries for directories
(including empty directories) in ZIP file.
2014-10-04 13:39:34 +03:00
Serhiy Storchaka 46a34924e4 Issue #20912: Now directories added to ZIP file have correct Unix and MS-DOS
directory attributes.
2014-09-23 22:40:23 +03:00
Serhiy Storchaka cfbb394488 Issue #21866: ZipFile.close() no longer writes ZIP64 central directory
records if allowZip64 is false.
2014-09-23 21:34:24 +03:00
Serhiy Storchaka 97f17ff840 Issue #22201: Command-line interface of the zipfile module now correctly
extracts ZIP files with directory entries.  Patch by Ryan Wilson.
2014-08-17 15:14:48 +03:00
Serhiy Storchaka b76bcc4ffc Issue #14099: Backout changeset e5bb3044402b (except adapted tests). 2015-01-26 13:45:39 +02:00
Gregory P. Smith 0af8a86be8 Fix issue #14315: The zipfile module now ignores extra fields in the central
directory that are too short to be parsed instead of letting a struct.unpack
error bubble up as this "bad data" appears in many real world zip files in the
wild and is ignored by other zip tools.
2014-05-29 23:42:14 -07:00
Serhiy Storchaka c46d1faa4a Issue #20262: Warnings are raised now when duplicate names are added in the
ZIP file or too long ZIP file comment is truncated.
2014-01-20 21:59:33 +02:00
Serhiy Storchaka 9b7a1a1af6 Issue #20262: Warnings are raised now when duplicate names are added in the
ZIP file or too long ZIP file comment is truncated.
2014-01-20 21:57:40 +02:00
Serhiy Storchaka 69fdbf9cb0 Issue #20078: Reading malformed zipfiles no longer hangs with 100% CPU
consumption.
2014-01-09 14:53:41 +02:00
Serhiy Storchaka 5ce3f10aee Issue #20078: Reading malformed zipfiles no longer hangs with 100% CPU
consumption.
2014-01-09 14:50:20 +02:00
Daniel Holth 9dee304205 Issue #18585: speed zipfile import by only generating zipfile._ZipDecryptor on demand 2014-01-02 23:17:21 -05:00
Serhiy Storchaka 6787a3806e Issue #15204: Deprecated the 'U' mode in file-like objects. 2013-11-23 22:12:06 +02:00
Serhiy Storchaka 235c5e0dd6 Issue #17201: ZIP64 extensions now are enabled by default.
Patch by William Mallard.
2013-11-23 15:55:38 +02:00
Christian Tismer 410d931a17 add filtering of individual files to PyZipFile
changed output of debug messages to say "path" or "file"
extended test for filtering  certain files in a package
added test for filtering files in a python dir (no package)
2013-10-22 04:09:28 +02:00
Christian Tismer 59202e5fc7 add a filterfunc to zip file.PyZipFile.writepy, issue 19274 2013-10-21 03:59:23 +02:00
Serhiy Storchaka ab25c7c011 Issue #19053: ZipExtFile.read1() with non-zero argument no more returns empty
bytes until end of data.
2013-09-27 22:14:31 +03:00
Serhiy Storchaka d2c07a58af Issue #19053: ZipExtFile.read1() with non-zero argument no more returns empty
bytes until end of data.
2013-09-27 22:11:57 +03:00
Brett Cannon 260fbe80c5 Issue #15767: Excise the remaining instances of ModuleNotFoundError 2013-07-04 18:16:15 -04:00
Brett Cannon b57a085c74 Issue #17177: Stop using imp in zipfile 2013-06-15 17:32:30 -04:00
Brett Cannon c9a1bfed5d Move test___all__ over to unittest.main() and use ModuleNotFoundError 2013-06-12 20:12:30 -04:00
Gregory P. Smith 7eca9624be Refactor recently added bugfix into more testable code by using a
method for windows file name sanitization.  Splits the unittest up
into several based on platform.
2013-02-03 00:37:36 -08:00
Gregory P. Smith 09aa752067 Refactor recently added bugfix into more testable code by using a
method for windows file name sanitization.  Splits the unittest up
into several based on platform.
2013-02-03 00:36:32 -08:00
Serhiy Storchaka fc23ec62a6 Fix the test for issue #6972.
Remove trailing dots on Windows.
2013-02-02 19:52:45 +02:00
Serhiy Storchaka 672671da47 Fix the test for issue #6972.
Remove trailing dots on Windows.
2013-02-02 19:51:37 +02:00
Serhiy Storchaka e5e6444497 Fix the test for issue #6972.
Remove trailing dots on Windows.
2013-02-02 19:50:59 +02:00
Gregory P. Smith ae42ec8004 Fixes Issue #6972: The zipfile module no longer overwrites files outside of
its destination path when extracting malicious zip files.
2013-02-01 11:35:00 -08:00
Gregory P. Smith 193e1be72d Fixes Issue #6972: The zipfile module no longer overwrites files outside of
its destination path when extracting malicious zip files.
2013-02-01 11:31:31 -08:00
Gregory P. Smith b47acbf46a Fixes Issue #6972: The zipfile module no longer overwrites files outside of
its destination path when extracting malicious zip files.
2013-02-01 11:22:43 -08:00
Serhiy Storchaka db58e15ee5 Issue #4844: ZipFile now raises BadZipFile when opens a ZIP file with an
incomplete "End of Central Directory" record.  Original patch by Guilherme
Polo and Alan McIntyre.
2013-01-31 15:30:36 +02:00
Serhiy Storchaka d72bfe9eb9 Issue #4844: ZipFile now raises BadZipFile when opens a ZIP file with an
incomplete "End of Central Directory" record.  Original patch by Guilherme
Polo and Alan McIntyre.
2013-01-31 15:29:20 +02:00
Serhiy Storchaka d2b1527f14 Issue #4844: ZipFile now raises BadZipFile when opens a ZIP file with an
incomplete "End of Central Directory" record.  Original patch by Guilherme
Polo and Alan McIntyre.
2013-01-31 15:27:07 +02:00
Serhiy Storchaka f7209225bb Issue #12004: Fix an internal error in PyZipFile when writing an invalid
Python file.  Patch by Ben Morgan.
2013-01-29 20:15:45 +02:00
Serhiy Storchaka c5b75db5de Issue #12004: Fix an internal error in PyZipFile when writing an invalid
Python file.  Patch by Ben Morgan.
2013-01-29 20:14:08 +02:00
Serhiy Storchaka 45c4375ea7 Issue #12004: Fix an internal error in PyZipFile when writing an invalid
Python file.  Patch by Ben Morgan.
2013-01-29 20:10:28 +02:00
Serhiy Storchaka 5f1cfbb5c0 Issue #9720: zipfile now writes correct local headers for files larger than 4 GiB. 2013-01-15 00:41:43 +02:00
Serhiy Storchaka 64bfcc4c22 Issue #9720: zipfile now writes correct local headers for files larger than 4 GiB. 2013-01-15 00:38:17 +02:00
Serhiy Storchaka 182d7cd531 Issue #9720: zipfile now writes correct local headers for files larger than 4 GiB. 2013-01-15 00:31:39 +02:00
Andrew Svetlov f7a17b48d7 Replace IOError with OSError (#16715) 2012-12-25 16:47:37 +02:00
Ezio Melotti 6a5fc4c443 #14313: zipfile now raises NotImplementedError when the compression type is unknown. 2012-11-18 13:20:36 +02:00
Antoine Pitrou 8f1fefab9a Issue #16408: Fix file descriptors not being closed in error conditions in the zipfile module.
Patch by Serhiy Storchaka.
2012-11-17 23:54:40 +01:00
Antoine Pitrou 8572da5e96 Issue #16408: Fix file descriptors not being closed in error conditions in the zipfile module.
Patch by Serhiy Storchaka.
2012-11-17 23:52:05 +01:00
Antoine Pitrou 17babc5e97 Issue #16408: Fix file descriptors not being closed in error conditions in the zipfile module.
Patch by Serhiy Storchaka.
2012-11-17 23:50:08 +01:00
Ezio Melotti 658f3522c6 #11981: remove duplicate line. Patch by Johan Euphrosine. 2012-11-17 18:56:15 +02:00
Antoine Pitrou 78157b3f6f On behalf of Nadeem Vawda: issue #10376: micro-optimize reading from a Zipfile.
(patch by Serhiy)
2012-06-23 16:44:48 +02:00
Nadeem Vawda a425c3d5a2 Make lzma.{encode,decode}_filter_properties private.
These functions were originally added to support LZMA compression in the zipfile
module, and are not of interest for the majority of users.

They can be made public in 3.4 if there is user interest, but in the meanwhile,
I've opted to present a smaller, simpler API for the module's initial release.
2012-06-21 23:36:48 +02:00
Martin v. Löwis 7fb79fcb64 Issue #14366: Support lzma compression in zip files.
Patch by Serhiy Storchaka.
2012-05-13 10:06:36 +02:00
Martin v. Löwis d099b56be7 Check extract_version when opening a zipfile. 2012-05-01 14:08:22 +02:00
Georg Brandl 5c01678174 Add missing comma in __all__ list. 2012-05-01 09:00:59 +02:00
Martin v. Löwis 2a2ce328fb Recognize unsupported feature "compressed patch data set" from zip 2.7. 2012-05-01 08:44:08 +02:00
Martin v. Löwis b3260f08cf Detect unsupported compression types. 2012-05-01 08:38:01 +02:00
Martin v. Löwis f6b16a4b50 Issue #14371: Support bzip2 in zipfile module.
Patch by Serhiy Storchaka.
2012-05-01 07:58:44 +02:00
Ezio Melotti 006917ec7f #14603: use a listcomp in ZipFile.namelist. 2012-04-16 21:34:24 -06:00
R David Murray f50b38a11f Merge #14399: zipfile now correctly handles comments added to empty zipfiles.
Patch by Serhiy Storchaka.

This also moves the TypeError that results from trying to use a unicode
comment from the 'close' step to the point at which the comment is added to
the zipfile.
2012-04-12 18:44:58 -04:00
R David Murray 51804e9725 #14399: zipfile now correctly handles comments added to empty zipfiles.
Patch by Serhiy Storchaka.

This also moves the TypeError that results from trying to use a unicode
comment from the 'close' step to the point at which the comment is added to
the zipfile.
2012-04-12 18:44:42 -04:00
Senthil Kumaran 29fa9d4d68 3.2 - Fix closes Issue6090 - Raise a ValueError, instead of failing with unrelated
exceptions, when a document with timestamp earlier than 1980 is provided to
zipfile. Patch contributed by  Petri Lehtinen.
2011-10-20 01:46:00 +08:00
R David Murray 4fbb9dbd34 #10694: zipfile now ignores garbage at the end of a zipfile.
Original fix by 'rep', final patch (with tests) by Xuanji Li.
2011-06-09 15:50:51 -04:00
Georg Brandl 5ba11de845 #10801: In zipfile, support different encodings for the header and the filenames. Patch by MvL, test by Eli Bendersky. 2011-01-01 10:09:32 +00:00
R. David Murray 8d855d8304 #4871: check that zipfile password is bytes, and give useful error message.
Previously passing a string in as the password would fail either with
an assertion error or a TypeError with a confusing error message.
Note that a string can't be accepted since zipfile has no way to
guess what encoding should be used to turn it into bytes.

Patch by Victor Stinner.
2010-12-21 21:53:37 +00:00
Georg Brandl 8334fd9285 Add an "optimize" parameter to compile() to control the optimization level, and provide an interface to it in py_compile, compileall and PyZipFile. 2010-12-04 10:26:46 +00:00
Łukasz Langa a9f054b423 zipfile: remove remaining ResourceWarnings 2010-11-23 00:15:02 +00:00
Łukasz Langa e94980a64f Issue #9846: ZipExtFile provides no mechanism for closing the underlying file object 2010-11-22 23:31:26 +00:00
Benjamin Peterson d285bdb443 start banging on zipfile's file leakiness 2010-10-31 17:57:22 +00:00
Éric Araujo ae2d8320a5 Fix typo from r85874 2010-10-28 13:49:17 +00:00
Georg Brandl 4d54088599 #7351: add more consistent exception name alias. 2010-10-28 06:42:33 +00:00
Georg Brandl 268e4d4cf3 #1710703: write zipfile structures also in the case of closing a new, but empty, archive. 2010-10-14 06:59:45 +00:00
Antoine Pitrou 6464d5ffdc Issue #9837: The read() method of ZipExtFile objects (as returned by
ZipFile.open()) could return more bytes than requested.
2010-09-12 14:51:20 +00:00
Antoine Pitrou 7c8bcb6f92 Issue #7467: when a file from a ZIP archive, its CRC is checked and a
BadZipfile error is raised if it doesn't match (as used to be the
case in Python 2.5 and earlier).
2010-08-12 15:11:50 +00:00
Barry Warsaw 28a691b7fd PEP 3147 2010-04-17 00:19:56 +00:00
Ronald Oussoren ee5c885fd2 Merged revisions 78097 via svnmerge from
svn+ssh://pythondev@svn.python.org/python/trunk

........
  r78097 | ronald.oussoren | 2010-02-07 21:18:02 +0100 (Sun, 07 Feb 2010) | 2 lines

  Issue 6003: ZipFile.writestr "compression_type" argument
........
2010-02-07 20:24:02 +00:00
Ezio Melotti 92b4743719 Merged revisions 77809 via svnmerge from
svn+ssh://pythondev@svn.python.org/python/trunk

........
  r77809 | ezio.melotti | 2010-01-28 03:41:30 +0200 (Thu, 28 Jan 2010) | 1 line

  avoid to use zlib when the compress type is not ZIP_DEFLATED
........
2010-01-28 01:44:41 +00:00
Antoine Pitrou a32f9a24df Merged revisions 77798 via svnmerge from
svn+ssh://pythondev@svn.python.org/python/trunk

........
  r77798 | antoine.pitrou | 2010-01-27 21:59:50 +0100 (mer., 27 janv. 2010) | 8 lines

  Issue #7610: Reworked implementation of the internal
  :class:`zipfile.ZipExtFile` class used to represent files stored inside
  an archive.  The new implementation is significantly faster and can
  be wrapped in a :class:`io.BufferedReader` object for more speedups.
  It also solves an issue where interleaved calls to `read()` and
  `readline()` give wrong results.  Patch by Nir Aides.
........
2010-01-27 21:18:57 +00:00
Ezio Melotti faa6b7f421 Merged revisions 77136 via svnmerge from
svn+ssh://pythondev@svn.python.org/python/trunk

........
  r77136 | ezio.melotti | 2009-12-30 08:14:51 +0200 (Wed, 30 Dec 2009) | 1 line

  #5511: Added the ability to use ZipFile as a context manager. Patch by Brian Curtin.
........
2009-12-30 12:34:59 +00:00
Ezio Melotti af30d2eeaa fix print statement 2009-09-25 21:35:24 +00:00