Commit Graph

61 Commits

Author SHA1 Message Date
Lars Gustäbel 8c06ccc058 Issue #4750: Store the basename of the original filename in
the gzip FNAME header as required by RFC 1952.
2009-10-29 09:15:00 +00:00
Philip Jenvey d846f1d4c2 #4351: more appropriate DeprecationWarning stacklevels 2009-05-08 02:28:39 +00:00
Antoine Pitrou b74fc2b5fe Issue #3860: GzipFile and BZ2File now support the context manager protocol. 2009-01-10 16:13:45 +00:00
Antoine Pitrou f0d2c3f730 Issue #4272: Add an optional argument to the GzipFile constructor to override the timestamp in the gzip stream. 2009-01-04 21:29:23 +00:00
Georg Brandl e08e3d0686 #2959: allow multiple close() calls for GzipFile. 2008-05-25 08:07:37 +00:00
Gregory P. Smith dd10284516 prevent a warning from the struct module when data size >= 2**32. 2008-03-23 23:45:12 +00:00
Gregory P. Smith ac830e932d A bugfix for r61813, it would fail if the data size was >=2**32. 2008-03-23 23:43:02 +00:00
Gregory P. Smith 79b4ba8fd7 Fix gzip to deal with CRC's being signed values in Python 2.x properly and to
read 32bit values as unsigned to start with rather than applying signedness
fixups allover the place afterwards.

This hopefully fixes the test_tarfile failure on the alpha/tru64 buildbot.
2008-03-23 21:04:43 +00:00
Gregory P. Smith f15cde3732 Improve the error message when the CRCs don't match. 2008-03-19 22:23:51 +00:00
Lars Gustäbel f19c1b5e0e Strip the '.gz' extension from the filename that is written to the
gzip header.
2007-02-13 16:24:00 +00:00
Lars Gustäbel 5b1a785702 Patch #1647484: Renamed GzipFile's filename attribute to name. The
filename attribute is still accessible as a property that emits a
DeprecationWarning.
2007-02-13 16:09:24 +00:00
Martin v. Löwis 065f0c8a06 Patch #1355023: support whence argument for GzipFile.seek. 2006-11-12 10:41:39 +00:00
Tim Peters 62decc9f49 Try to squash struct.pack warnings on the "amd64 gentoo trunk"
buildbot (& possibly other 64-bit boxes) during test_gzip.

The native zlib crc32 function returns an unsigned 32-bit integer,
which the Python wrapper implicitly casts to C long.  Therefore the
same crc can "look negative" on a 32-bit box but "look positive" on
a 64-bit box.  This patch papers over that platform difference when
writing the crc to file.

It may be better to change the Python wrapper, either to make
the result "look positive" on all platforms (which means it may
have to return a Python long at times on a 32-bit box), or to
keep the sign the same across boxes.  But that would be a visible
change in what users see, while the current hack changes no
visible behavior (well, apart from stopping the struct deprecation
warning).

Note that the module-level write32() function is no longer used.
2006-08-02 04:12:36 +00:00
Bob Ippolito d82c3105cc Apply revised patch for GzipFile.readline performance #1281707 2006-05-22 15:59:12 +00:00
Bob Ippolito b97597316b Revert gzip readline performance patch #1281707 until a more generic performance improvement can be found 2006-05-22 15:22:46 +00:00
Bob Ippolito d72aab5e31 GzipFile.readline performance improvement (~30-40%), patch #1281707 2006-05-22 14:31:24 +00:00
Andrew M. Kuchling 01cb47b59c [Bug #1074261, patch #1074381] Restrict the size of chunks read from the file in order to avoid overflow or huge memory consumption. Patch by Mark Eichin 2005-06-09 14:19:32 +00:00
Tim Peters eba28bea9b Whitespace normalization. 2005-03-28 01:08:02 +00:00
Martin v. Löwis f2a8d63e4f Patch #1110248: SYNC_FLUSH the zlib buffer for GZipFile.flush.
Partially fixes #1110242.
2005-03-03 08:35:22 +00:00
Tim Peters 49667c257b Ack, removed useless import of os I just introduced. 2004-07-27 21:05:21 +00:00
Tim Peters 5cfb05eef0 Added a new fileno() method. ZODB's repozo.py wants this so it can
apply os.fsync() to the GzipFile backup files it creates.
2004-07-27 21:02:02 +00:00
Walter Dörwald 70a6b49821 Replace backticks with repr() or "%r"
From SF patch #852334.
2004-02-12 17:35:32 +00:00
Brett Cannon edfb30258e Fix error in exception message. 2003-12-04 19:28:06 +00:00
Andrew M. Kuchling 64edd6ac1d [Patch #654421 from Matthew Mueller]
gzip shouldn't raise ValueError on corrupt files

  Currently the gzip module will raise a ValueError if the file was
  corrupt (bad crc or bad size).  I can't see how that applies to
  reading a corrupt file.  IOError seems better, and it's what code
  will likely be looking for.
2003-02-05 21:35:07 +00:00
Tim Peters 9288f95cb5 Another round on SF patch 618135: gzip.py and files > 2G
The last round boosted "the limit" from 2GB to 4GB.  This round gets
rid of the 4GB limit.  For files > 4GB, gzip stores just the last 32
bits of the file size, and now we play along with that too.  Tested
by hand (on a 6+GB file) on Win2K.

Boosting from 2GB to 4GB was arguably enough "a bugfix".  Going beyond
that smells more like "new feature" to me.
2002-11-05 20:38:55 +00:00
Tim Peters fb0ea525d5 Related to SF patch 618135: gzip.py and files > 2G.
Fixed the signed/unsigned confusions when dealing with files >= 2GB.
4GB is still a hard limitation of the gzip file format, though.

Testing this was a bitch on Win98SE due to frequent system freezes.  It
didn't freeze while running gzip, it kept freezing while trying to *create*
a > 2GB test file!  This wasn't Python's doing.  I don't know of a
reasonable way to test this functionality in regrtest.py, so I'm not
checking in a test case (a test case would necessarily require creating
a 2GB+ file first, using gzip to zip it, using gzip to unzip it again,
and then compare before-and-after; so >4GB free space would be required,
and a loooong time; I did all this "by hand" once).

Bugfix candidate, I guess.
2002-11-04 19:50:11 +00:00
Guido van Rossum 97c5fccd77 Remove mention of deprecated xreadlines method. 2002-08-06 17:03:25 +00:00
Raymond Hettinger aef22fb9cd Patch 560023 adding docstrings. 2.2 Candidate (after verifying modules were not updated after 2.2). 2002-05-29 16:18:42 +00:00
Skip Montanaro 12424bc0ef force gzip module to open files using 'b'inary mode.
closes patch #536278.
2002-05-23 01:43:05 +00:00
Tim Peters 863ac44b74 Whitespace normalization. 2002-04-16 01:38:40 +00:00
Guido van Rossum 8ca162f417 Partial introduction of bools where appropriate. 2002-04-07 06:36:23 +00:00
Neil Schemenauer cacbdf6229 Make GzipFile an iterator. Closes bug #532621. 2002-03-20 18:36:00 +00:00
Martin v. Löwis db04489953 Patch #443899: Check modes on files before performing operations.
Use IOErrors where file objects use them.
2002-03-11 06:46:52 +00:00
Fred Drake 95b0eb7cb3 "f" should be "self"; reported by Neal Norwitz. 2001-10-13 18:33:51 +00:00
Andrew M. Kuchling f31d31373e Remove redefinition of writelines() method
Remove unused variable and import
2001-08-13 14:54:12 +00:00
Tim Peters ab9ba27dc0 Whitespace normalization. 2001-08-09 21:40:30 +00:00
Martin v. Löwis 8cc965c1fb Patch #448474: Add support for tell() and seek() to gzip.GzipFile. 2001-08-09 07:21:56 +00:00
Andrew M. Kuchling 44f5f8fb26 Bug #409419: delete seek() and tell() methods, so callers can use getattr()
to check for them (instead of calling them and then ignoring an
    IOError)
2001-03-20 15:51:14 +00:00
Jack Jansen 2d0589be67 The code to write timestamps couldn't handle negative times (and time
on the Mac is negativevalues > 0x80000000). Fixed.
2001-02-21 10:39:35 +00:00
Eric S. Raymond ee5e61d3bc String method conversion. 2001-02-09 09:10:35 +00:00
Skip Montanaro 2dd4276559 added a few more __all__ lists
fixed typo in ihooks docstring
2001-01-23 15:35:05 +00:00
Tim Peters 07e99cb774 Whitespace normalization. 2001-01-14 23:47:14 +00:00
Andrew M. Kuchling 41616ee194 SF patch #100740: Add optional size arguments to .readline() and
.readlines() methods.  Inspired by a patch from Wolfgang Grafen,
though this version of the patch was completely rewritten from his
code.
2000-07-29 20:15:26 +00:00
Jeremy Hylton e298c3018c if the GzipFile constructor fails, the __del__ method is still
called.  catch the resulting AttributeError and exit cleanly.
2000-05-08 16:59:59 +00:00
Guido van Rossum 4b8c6eaf8b Actually, the previous batch's comment should have been different;
*this* set of patches is Ka-Ping's final sweep:

The attached patches update the standard library so that all modules
have docstrings beginning with one-line summaries.

A new docstring was added to formatter.  The docstring for os.py
was updated to mention nt, os2, ce in addition to posix, dos, mac.
2000-02-04 15:39:30 +00:00
Guido van Rossum 54f22ed30b More trivial comment -> docstring transformations by Ka-Ping Yee,
who writes:

Here is batch 2, as a big collection of CVS context diffs.
Along with moving comments into docstrings, i've added a
couple of missing docstrings and attempted to make sure more
module docstrings begin with a one-line summary.

I did not add docstrings to the methods in profile.py for
fear of upsetting any careful optimizations there, though
i did move class documentation into class docstrings.

The convention i'm using is to leave credits/version/copyright
type of stuff in # comments, and move the rest of the descriptive
stuff about module usage into module docstrings.  Hope this is
okay.
2000-02-04 15:10:34 +00:00
Guido van Rossum 5606801b64 Make read() and readlines() conform more to the file object interface:
the default arg for read() is -1, not None, and readlines() has an
optional argument (which for now is ignored).
2000-02-02 16:51:06 +00:00
Andrew M. Kuchling 2d813e5140 Fixed 'return EOFError' that should be 'raise EOFError', caught by
Skip Montanaro's return-value patches.
1999-09-06 16:34:51 +00:00
Andrew M. Kuchling 916fcc3b18 Added __del__ method to GzipFile class that will flush and close the
object, if required.
1999-08-10 13:19:30 +00:00
Guido van Rossum 95bdd0b604 Two different changes.
1. Jack Jansen reports that on the Mac, the time may be negative, and
solves this by adding a write32u() function that writes an unsigned
long.

2. On 64-bit platforms the CRC comparison fails; I've fixed this by
casting both values to be compared to "unsigned long" i.e. modulo
0x100000000L.
1999-04-12 14:34:16 +00:00