summaryrefslogtreecommitdiffstats
path: root/Lib
diff options
context:
space:
mode:
Diffstat (limited to 'Lib')
-rw-r--r--Lib/gzip.py10
-rw-r--r--Lib/test/test_gzip.py10
2 files changed, 18 insertions, 2 deletions
diff --git a/Lib/gzip.py b/Lib/gzip.py
index d51b7db..9cab995 100644
--- a/Lib/gzip.py
+++ b/Lib/gzip.py
@@ -5,7 +5,7 @@ but random access is not allowed."""
# based on Andrew Kuchling's minigzip.py distributed with the zlib module
-import struct, sys, time
+import os, struct, sys, time
import zlib
import __builtin__
@@ -334,6 +334,14 @@ class GzipFile:
def flush(self):
self.fileobj.flush()
+ def fileno(self):
+ """Invoke the underlying file object's fileno() method.
+
+ This will raise AttributeError if the underlying file object
+ doesn't support fileno().
+ """
+ return self.fileobj.fileno()
+
def isatty(self):
return False
diff --git a/Lib/test/test_gzip.py b/Lib/test/test_gzip.py
index bb4ed49..81a4865 100644
--- a/Lib/test/test_gzip.py
+++ b/Lib/test/test_gzip.py
@@ -16,8 +16,16 @@ data2 = """/* zlibmodule.c -- gzip-compatible data compression */
/* See http://www.winimage.com/zLibDll for Windows */
"""
-f = gzip.GzipFile(filename, 'wb') ; f.write(data1 * 50) ; f.close()
+f = gzip.GzipFile(filename, 'wb') ; f.write(data1 * 50)
+# Try flush and fileno.
+f.flush()
+f.fileno()
+if hasattr(os, 'fsync'):
+ os.fsync(f.fileno())
+f.close()
+
+# Try reading.
f = gzip.GzipFile(filename, 'r') ; d = f.read() ; f.close()
verify(d == data1*50)