diff options
| author | Georg Brandl <georg@python.org> | 2011-09-22 14:28:31 +0200 |
|---|---|---|
| committer | Georg Brandl <georg@python.org> | 2011-09-22 14:28:31 +0200 |
| commit | 75a6e2ee6216598fd5010c0a66b57f43ff66e2f6 (patch) | |
| tree | 0ed3d05e31720218e65b65cc5196fecf0d8b3205 | |
| parent | 85c2f0b5c464abc587bdfae6cc7ccfd747eb2ae2 (diff) | |
| download | sphinx-75a6e2ee6216598fd5010c0a66b57f43ff66e2f6.tar.gz | |
Always close .buildinfo file after reading.
| -rw-r--r-- | sphinx/builders/html.py | 24 |
1 files changed, 13 insertions, 11 deletions
diff --git a/sphinx/builders/html.py b/sphinx/builders/html.py index 8ff628c9..ca3d6161 100644 --- a/sphinx/builders/html.py +++ b/sphinx/builders/html.py @@ -159,17 +159,19 @@ class StandaloneHTMLBuilder(Builder): old_config_hash = old_tags_hash = '' try: fp = open(path.join(self.outdir, '.buildinfo')) - version = fp.readline() - if version.rstrip() != '# Sphinx build info version 1': - raise ValueError - fp.readline() # skip commentary - cfg, old_config_hash = fp.readline().strip().split(': ') - if cfg != 'config': - raise ValueError - tag, old_tags_hash = fp.readline().strip().split(': ') - if tag != 'tags': - raise ValueError - fp.close() + try: + version = fp.readline() + if version.rstrip() != '# Sphinx build info version 1': + raise ValueError + fp.readline() # skip commentary + cfg, old_config_hash = fp.readline().strip().split(': ') + if cfg != 'config': + raise ValueError + tag, old_tags_hash = fp.readline().strip().split(': ') + if tag != 'tags': + raise ValueError + finally: + fp.close() except ValueError: self.warn('unsupported build info format in %r, building all' % path.join(self.outdir, '.buildinfo')) |
