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)
class TestGzip(unittest.TestCase):
filename = test_support.TESTFN
- def setUp (self):
+ def setUp(self):
test_support.unlink(self.filename)
- def tearDown (self):
+ def tearDown(self):
test_support.unlink(self.filename)
- def test_write (self):
+ def test_write(self):
f = gzip.GzipFile(self.filename, 'wb') ; f.write(data1 * 50)
# Try flush and fileno.
os.fsync(f.fileno())
f.close()
+ # Test multiple close() calls.
+ f.close()
+
def test_read(self):
self.test_write()
# Try reading.
Library
-------
+- Issue #2959: For consistency with other file-like objects, gzip's
+ GzipFile.close() can now be called multiple times without raising
+ an exception.
+
- Issue #1390: Raise ValueError in toxml when an invalid comment would
otherwise be produced.