Always close .buildinfo file after reading.

This commit is contained in:
Georg Brandl 2011-09-22 14:28:31 +02:00
parent 3d4b8830a0
commit f250397f77

View File

@ -159,17 +159,19 @@ class StandaloneHTMLBuilder(Builder):
old_config_hash = old_tags_hash = '' old_config_hash = old_tags_hash = ''
try: try:
fp = open(path.join(self.outdir, '.buildinfo')) fp = open(path.join(self.outdir, '.buildinfo'))
version = fp.readline() try:
if version.rstrip() != '# Sphinx build info version 1': version = fp.readline()
raise ValueError if version.rstrip() != '# Sphinx build info version 1':
fp.readline() # skip commentary raise ValueError
cfg, old_config_hash = fp.readline().strip().split(': ') fp.readline() # skip commentary
if cfg != 'config': cfg, old_config_hash = fp.readline().strip().split(': ')
raise ValueError if cfg != 'config':
tag, old_tags_hash = fp.readline().strip().split(': ') raise ValueError
if tag != 'tags': tag, old_tags_hash = fp.readline().strip().split(': ')
raise ValueError if tag != 'tags':
fp.close() raise ValueError
finally:
fp.close()
except ValueError: except ValueError:
self.warn('unsupported build info format in %r, building all' % self.warn('unsupported build info format in %r, building all' %
path.join(self.outdir, '.buildinfo')) path.join(self.outdir, '.buildinfo'))