diff options
Diffstat (limited to 'Lib/quopri.py')
-rwxr-xr-x | Lib/quopri.py | 14 |
1 files changed, 8 insertions, 6 deletions
diff --git a/Lib/quopri.py b/Lib/quopri.py index 62c0503..6b3d13e 100755 --- a/Lib/quopri.py +++ b/Lib/quopri.py @@ -227,12 +227,14 @@ def main(): sys.stderr.write("%s: can't open (%s)\n" % (file, msg)) sts = 1 continue - if deco: - decode(fp, sys.stdout.buffer) - else: - encode(fp, sys.stdout.buffer, tabs) - if fp is not sys.stdin: - fp.close() + try: + if deco: + decode(fp, sys.stdout.buffer) + else: + encode(fp, sys.stdout.buffer, tabs) + finally: + if file != '-': + fp.close() if sts: sys.exit(sts) |