diff options
author | Stuart Rackham <srackham@methods.co.nz> | 2011-02-08 07:59:42 +1300 |
---|---|---|
committer | Stuart Rackham <srackham@methods.co.nz> | 2011-02-08 07:59:42 +1300 |
commit | 7461417cbe9cad3bfc41d1a331df9a0afb622f1e (patch) | |
tree | 23f4ae82e77ab6a6ef2ff4a6cf20ab69281565a5 | |
parent | 82325eeb449498f6f71806fd633636cb5b4620d3 (diff) | |
download | asciidoc-7461417cbe9cad3bfc41d1a331df9a0afb622f1e.tar.gz |
Ensure the --filter install command closes output file handles on error.
-rwxr-xr-x | asciidoc.py | 7 |
1 files changed, 5 insertions, 2 deletions
diff --git a/asciidoc.py b/asciidoc.py index d3c9dfb..c0912e6 100755 --- a/asciidoc.py +++ b/asciidoc.py @@ -5368,10 +5368,13 @@ def unzip(zip_file, destdir): if not os.path.isdir(directory): os.makedirs(directory) outfile = os.path.join(directory, outfile) - perms = (zi.external_attr >> 16L) & 0777 + perms = (zi.external_attr >> 16) & 0777 message.verbose('extracting: %s' % outfile) fh = os.open(outfile, os.O_CREAT | os.O_WRONLY, perms) - os.write(fh, zipo.read(zi.filename)) + try: + os.write(fh, zipo.read(zi.filename)) + finally: + os.close(fh) finally: zipo.close() |