diff options
author | Lars Wirzenius <lars.wirzenius@codethink.co.uk> | 2012-10-12 14:33:30 +0100 |
---|---|---|
committer | Lars Wirzenius <lars.wirzenius@codethink.co.uk> | 2012-10-12 17:01:54 +0100 |
commit | d0111fbd2de1d046b14046f2cb0ded14d058cfdd (patch) | |
tree | 2e531268b9b9aee9ea6a5ecfd5efeb5fe6b4bf0b /morphlib/builder2.py | |
parent | e3aa8ba25847397a03a665492a0cbe4541814246 (diff) | |
download | morph-d0111fbd2de1d046b14046f2cb0ded14d058cfdd.tar.gz |
Fix use of GzipFile to not assume "with" protocol
This fixes a bunch of tests so they pass on squeeze, which has a version
of Python whose GzipFile doesn't support the "with" protocol.
Diffstat (limited to 'morphlib/builder2.py')
-rw-r--r-- | morphlib/builder2.py | 7 |
1 files changed, 4 insertions, 3 deletions
diff --git a/morphlib/builder2.py b/morphlib/builder2.py index 856587a2..565fdf4f 100644 --- a/morphlib/builder2.py +++ b/morphlib/builder2.py @@ -706,9 +706,10 @@ class DiskImageBuilder(SystemKindBuilder): # pragma: no cover self.app.status(msg='Compressing disk image', chatty=True) with os.fdopen(image_file_fd, "rb") as ifh: - with gzip.GzipFile(fileobj=handle, mode="wb", - compresslevel=1) as ofh: - shutil.copyfileobj(ifh, ofh, 1024 * 1024) + ofh = gzip.GzipFile( + fileobj=handle, mode="wb", compresslevel=1) + shutil.copyfileobj(ifh, ofh, 1024 * 1024) + ofh.close() except: os.remove(image_name) |