diff options
author | Ned Batchelder <ned@nedbatchelder.com> | 2011-01-30 11:49:52 -0500 |
---|---|---|
committer | Ned Batchelder <ned@nedbatchelder.com> | 2011-01-30 11:49:52 -0500 |
commit | 16943d29886df91300121fced970134d0c2b9806 (patch) | |
tree | 0e621681a8c90b7c7e3dabcaa0b241693129846b /coverage/html.py | |
parent | fefc80883476d3974b3aee692ab274d1f563f7bb (diff) | |
download | python-coveragepy-git-16943d29886df91300121fced970134d0c2b9806.tar.gz |
A bunch more places where a file close should be in a finally clause.
Diffstat (limited to 'coverage/html.py')
-rw-r--r-- | coverage/html.py | 12 |
1 files changed, 8 insertions, 4 deletions
diff --git a/coverage/html.py b/coverage/html.py index b68cc936..bf49002f 100644 --- a/coverage/html.py +++ b/coverage/html.py @@ -145,8 +145,10 @@ class HtmlReporter(Reporter): html_path = os.path.join(self.directory, html_filename) html = spaceless(self.source_tmpl.render(locals())) fhtml = open(html_path, 'w') - fhtml.write(html) - fhtml.close() + try: + fhtml.write(html) + finally: + fhtml.close() # Save this file's information for the index file. self.files.append({ @@ -166,8 +168,10 @@ class HtmlReporter(Reporter): totals = sum([f['nums'] for f in files]) fhtml = open(os.path.join(self.directory, "index.html"), "w") - fhtml.write(index_tmpl.render(locals())) - fhtml.close() + try: + fhtml.write(index_tmpl.render(locals())) + finally: + fhtml.close() # Helpers for templates and generating HTML |