From 756d99ddf8e83923115e11b0641148ebdf80ee66 Mon Sep 17 00:00:00 2001 From: Oleg Broytman Date: Wed, 5 Feb 2014 19:42:28 +0400 Subject: [PATCH] Close infile and outfile even after an exception --- mimedecode.py | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) 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() -- 2.39.5