From: Oleg Broytman Date: Wed, 5 Feb 2014 15:42:28 +0000 (+0400) Subject: Close infile and outfile even after an exception X-Git-Tag: v2.3.4~6 X-Git-Url: https://git.phdru.name/?a=commitdiff_plain;h=756d99ddf8e83923115e11b0641148ebdf80ee66;p=mimedecode.git Close infile and outfile even after an exception --- diff --git a/mimedecode.py b/mimedecode.py index 78783ae..692a0f0 100755 --- a/mimedecode.py +++ b/mimedecode.py @@ -390,7 +390,8 @@ if __name__ == "__main__": gopts.outfile = outfile output = outfile.write - decode_file(infile) - - infile.close() - outfile.close() + try: + decode_file(infile) + finally: + infile.close() + outfile.close()