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:
f = gzip.GzipFile(filename, 'wb') ; f.write(data1 * 50) ; f.close()
-f = gzip.GzipFile(filename, 'rb') ; d = f.read() ; f.close()
+f = gzip.GzipFile(filename, 'r') ; d = f.read() ; f.close()
verify(d == data1*50)
# Append to the previous file
f.write('GZ\n')
f.close()
+f = gzip.GzipFile(filename, 'r')
+verify(f.myfileobj.mode == 'rb')
+f.close()
+
os.unlink(filename)