#2959: allow multiple close() calls for GzipFile.
diff --git a/Lib/gzip.py b/Lib/gzip.py
index eeef3f8..7a3f813 100644
--- a/Lib/gzip.py
+++ b/Lib/gzip.py
@@ -306,6 +306,8 @@
             raise IOError, "Incorrect length of data produced"
 
     def close(self):
+        if self.fileobj is None:
+            return
         if self.mode == WRITE:
             self.fileobj.write(self.compress.flush())
             write32u(self.fileobj, self.crc)