]> git.ipfire.org Git - thirdparty/Python/cpython.git/commitdiff
backport montanaro's checkin of
authorMichael W. Hudson <mwh@python.net>
Fri, 23 Aug 2002 16:09:52 +0000 (16:09 +0000)
committerMichael W. Hudson <mwh@python.net>
Fri, 23 Aug 2002 16:09:52 +0000 (16:09 +0000)
    revision 1.33 of gzip.py

force gzip module to open files using 'b'inary mode.
closes patch #536278.

This looked like a bugfix candidate to me at some point...

Lib/gzip.py

index 7f561532add527780f143e2b1d30a7cc1f48220f..efd072519c90f9f70bded39b454a2581969a2272 100644 (file)
@@ -35,6 +35,10 @@ class GzipFile:
 
     def __init__(self, filename=None, mode=None,
                  compresslevel=9, fileobj=None):
+        # guarantee the file is opened in binary mode on platforms
+        # that care about that sort of thing
+        if mode and 'b' not in mode:
+            mode += 'b'
         if fileobj is None:
             fileobj = self.myfileobj = __builtin__.open(filename, mode or 'rb')
         if filename is None: