Commit Graph

76 Commits

Author SHA1 Message Date
Antoine Pitrou e1436d1092 Merged revisions 83959-83960 via svnmerge from
svn+ssh://pythondev@svn.python.org/python/branches/py3k

........
  r83959 | antoine.pitrou | 2010-08-12 17:11:50 +0200 (jeu., 12 août 2010) | 5 lines

  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).
........
  r83960 | antoine.pitrou | 2010-08-12 17:15:01 +0200 (jeu., 12 août 2010) | 3 lines

  Typo.
........
2010-08-12 15:25:51 +00:00
Ronald Oussoren dd25e86cf4 Issue 6003: ZipFile.writestr "compression_type" argument 2010-02-07 20:18:02 +00:00
Ezio Melotti 4611b05bd8 avoid to use zlib when the compress type is not ZIP_DEFLATED 2010-01-28 01:41:30 +00:00
Antoine Pitrou 94c33ebfa8 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 20:59:50 +00:00
Ezio Melotti 569e61f351 #5511: Added the ability to use ZipFile as a context manager. Patch by Brian Curtin. 2009-12-30 06:14:51 +00:00
Amaury Forgeot d'Arc 3e5b027a64 #6511: ZipFile will now raise BadZipfile when opening an empty or tiny file,
like it does for larger invalid files.
2009-07-28 22:15:30 +00:00
Gregory P. Smith 2662733bce Fixes the last problem mentioned in issue1202. 2009-06-26 07:50:21 +00:00
Martin v. Löwis 0b09c42ffe Issue #6050: Don't fail extracting a directory from a zipfile if
the directory already exists.
2009-05-24 19:30:52 +00:00
Benjamin Peterson b91e8ede7a make sure files are closed using the with statement 2009-05-10 02:29:00 +00:00
Antoine Pitrou 97377bf566 Issue #5692: In :class:`zipfile.Zipfile`, fix wrong path calculation when extracting a file to the root directory. 2009-05-04 21:17:17 +00:00
Benjamin Peterson bf6c410b2e revert unrelated change 2009-05-02 17:35:39 +00:00
Benjamin Peterson 6282169142 remove py3k compat code 2009-05-02 17:33:01 +00:00
Martin v. Löwis 0dfcfc8b59 Issue #4710: Extract directories properly in the zipfile module;
allow adding directories to a zipfile.
2009-01-24 14:00:33 +00:00
Amaury Forgeot d'Arc 2407ac9a4b follow-up of #3997: since 0xFFFF numbers are not enough to indicate a zip64 format,
always try to read the "zip64 end of directory structure".
2009-01-17 22:43:50 +00:00
Amaury Forgeot d'Arc d25f87ae36 #3997: zipfiles generated with more than 65536 files could not be opened
with other applications.

Reviewed by Martin, will backport to 2.6 and 3.0
2009-01-17 16:40:17 +00:00
Antoine Pitrou 6f193e0e95 Issue #4756: zipfile.is_zipfile() now supports file-like objects.
Patch by Gabriel Genellina.
2008-12-27 15:43:12 +00:00
Antoine Pitrou ebcd0ced14 Issue #3535: zipfile couldn't read some zip files larger than 2GB.
Reviewed by Amaury Forgeot d'Arc.
2008-09-05 23:30:23 +00:00
Antoine Pitrou c53427087e fix ZipFile.testzip() to work with very large embedded files 2008-08-17 13:06:29 +00:00
Antoine Pitrou 5fdfa3e36d #3394: zipfile.writestr doesn't set external attributes, so files are extracted mode 000 on Unix 2008-07-25 19:42:26 +00:00
Amaury Forgeot d'Arc ae6d2b9175 #3317 in zipfile module, restore the previous names of global variables:
some applications relied on them.

Also remove duplicated lines.
2008-07-11 21:28:25 +00:00
Martin v. Löwis 8c43641271 Patch #1622: Correct interpretation of various ZIP header fields.
Also fixes
- Issue #1526: Allow more than 64k files to be added to Zip64 file.

- Issue #1746: Correct handling of zipfile archive comments (previously
  archives with comments over 4k were flagged as invalid). Allow writing
  Zip files with archives by setting the 'comment' attribute of a ZipFile.
2008-07-03 12:51:14 +00:00
Georg Brandl 112aa50329 Patch #1775025: allow opening zipfile members via ZipInfo instances.
Patch by Graham Horler.
2008-05-20 08:25:48 +00:00
Martin v. Löwis 471617d6d3 Issue #1734346: Support Unicode file names for zipfiles. 2008-05-05 17:16:58 +00:00
Gregory P. Smith bf02e3bb21 Fix the struct module DeprecationWarnings that zipfile was triggering by
removing all use of signed struct values.

test_zipfile and test_zipfile64 pass.  no more warnings.
2008-03-19 03:14:41 +00:00
Gregory P. Smith b89a096d6d Use zlib's crc32 routine instead of binascii when available. zlib's is faster
when compiled properly optimized and about the same speed otherwise.
2008-03-19 01:46:10 +00:00
Gregory P. Smith da407232e0 Document that zipfile decryption is insanely slow and fix a typo and
blatant lie in a docstring (it is not useful for security regardless of
how you spell it).
2008-01-20 01:32:00 +00:00
Gregory P. Smith 0c63fc23c4 Fix zipfile decryption. The check for validity only worked on one
type of encrypted zip files.  Files using extended local headers
needed to compare the check byte against different values.  (according
to reading the infozip unzip crypt.c source code)

Fixes issue1003.
2008-01-20 01:21:03 +00:00
Gregory P. Smith 350d03b18a Fixes/Accepts Patch for issue1189216 - Work properly with archives
that have file headers past the 2**31 byte boundary.
2008-01-19 23:10:52 +00:00
Raymond Hettinger 351e1a3e88 Fix 1698398: Zipfile.printdir() crashed because the format string expected a tuple object of length six instead of a time.struct_time object. 2008-01-14 22:58:05 +00:00
Georg Brandl 62416bcf5a #467924, patch by Alan McIntyre: Add ZipFile.extract and ZipFile.extractall. 2008-01-07 18:47:44 +00:00
Georg Brandl 4b3ab6fcc0 Patch #1675424: Added tests for uncovered code in the zipfile module.
The KeyError raised by Zipfile.getinfo for nonexistent names now has
  a descriptive message.
2007-07-12 09:59:22 +00:00
Tim Peters ea5962f86e Whitespace normalization. 2007-03-12 18:07:52 +00:00
Martin v. Löwis 3eb7648986 Patch #1121142: Implement ZipFile.open. 2007-03-06 10:41:24 +00:00
Martin v. Löwis 84f6de9d7e Patch #1517891: Make 'a' create the file if it doesn't exist.
Fixes #1514451.
2007-02-13 10:10:39 +00:00
Martin v. Löwis c6d626ed9f Patch #698833: Support file decryption in zipfile. 2007-02-13 09:49:38 +00:00
Tim Peters f79c32dbfb ZipFile.close(): Kill the other struct.pack deprecation
warning on Windows.

Afraid I can't detect a pattern to when the pack formats decide
to use a signed or unsigned format code -- appears nearly
arbitrary to my eyes.  So I left all the pack formats alone and
changed the special-case data values instead.
2006-07-31 02:53:03 +00:00
Tim Peters 352bf0d7ee ZipFile.close(): Killed one of the struct.pack deprecation
warnings on Win32.

Also added an XXX about the line:

                pos3 = self.fp.tell()

`pos3` is never referenced, and I have no idea what the code
intended to do instead.
2006-07-31 02:40:23 +00:00
Tim Peters a608bb228c Whitespace normalization. 2006-06-15 18:06:29 +00:00
Ronald Oussoren 143cefb846 Patch #1446489 (zipfile: support for ZIP64) 2006-06-15 08:14:18 +00:00
Georg Brandl 8f7c54eaa5 Bug #1413790: zipfile now sanitizes absolute archive names that are
not allowed by the specs.
2006-02-20 08:40:38 +00:00
Martin v. Löwis 0075690ced Patch #1412872: zipfile: use correct system type on unixy systems. 2006-02-05 17:09:41 +00:00
Raymond Hettinger 2ca7c190b6 Remove dependency on order of mode flags 2005-02-16 09:27:49 +00:00
Raymond Hettinger 8a92dd5866 Don't choke on modes like rb or wb. 2004-11-06 00:31:51 +00:00
Brett Cannon ff450f7512 Make struct formats for specifying file size to be unsigned instead of signed
(ZIP file spec. says in section K, "General notes" in point 1 that unless
specified otherwise values are unsigned and they are not specified as signed in
the spec).

Closes bug #679953.  Thanks Jimmy Burgett.
2004-07-10 19:09:20 +00:00
Andrew M. Kuchling 55430213c5 [Bug #835415] AIX can return modes that are >65536, which causes an OverflowError. Fix from Albert Chin 2004-07-10 15:40:29 +00:00
Raymond Hettinger c0fac96c29 SF patch #756996: Bare except in ZipFile.testzip()
(Contributed by Steven Taschuk)

Replaces a bare except that caused all errors to be mis-reported as
archive errors.

Added a related NEWS item.
2003-06-27 22:25:03 +00:00
Greg Ward 9b15878369 Remove debug print on filename with NUL byte. 2003-06-18 00:54:28 +00:00
Greg Ward 8e36d28f3c SF patch #755987 (Jim Ahlstrom):
This is a patch for Bug 755031: If a null byte appears in
a file name, Python zipfile.py retains it, but InfoZip
terminates the name. Null bytes in file names are used
as a trick by viruses. I tested WinZip, and it also
truncates the file name at the null byte.

The patch also fixes a buglet: If a zipfile incorrectly
uses a directory separator other than '/', there was an
invalid complaint that the central directory name does
not match the file header name.

I also removed my name from the top of the file. It was
there for legal reasons which I believe no longer apply.
Many people have worked on this file besides me.
2003-06-18 00:53:06 +00:00
Martin v. Löwis 0c6774d92b Patch #661719: Expose compilation errors as exceptions on request. 2003-01-15 11:51:06 +00:00
Just van Rossum b083cb3901 Patch #651621, approved by MvL.
This patch allows ZipFile.writestr() to be called with
an archive file name instead of a ZipInfo instance:

z = ZipFile("myarchive.zip", "w")
z.writestr("foo/baz/file.ext", data)
z.close()

I found the old writestr() method very inconvenient
for simple (but common) things.

If called with a file name instead of a ZipInfo
instance, the date_time is set to the current date/time,
which makes sense to me for anonymous data.
2002-12-12 12:23:32 +00:00