]> git.ipfire.org Git - thirdparty/Python/cpython.git/commitdiff
Jython compatibility fix: if uu.decode() opened its output file, be sure to
authorAndrew M. Kuchling <amk@amk.ca>
Mon, 20 Nov 2006 13:40:36 +0000 (13:40 +0000)
committerAndrew M. Kuchling <amk@amk.ca>
Mon, 20 Nov 2006 13:40:36 +0000 (13:40 +0000)
close it.

Lib/uu.py

index f5917983f6b9230e336795a945e5b512a8277191..fd3e32731f4575ec0e4b4491333337dda8519ccf 100755 (executable)
--- a/Lib/uu.py
+++ b/Lib/uu.py
@@ -115,6 +115,7 @@ def decode(in_file, out_file=None, mode=None, quiet=0):
     #
     # Open the output file
     #
+    opened = False
     if out_file == '-':
         out_file = sys.stdout
     elif isinstance(out_file, StringType):
@@ -124,6 +125,7 @@ def decode(in_file, out_file=None, mode=None, quiet=0):
         except AttributeError:
             pass
         out_file = fp
+        opened = True
     #
     # Main decoding loop
     #
@@ -141,6 +143,8 @@ def decode(in_file, out_file=None, mode=None, quiet=0):
         s = in_file.readline()
     if not s:
         raise Error, 'Truncated input file'
+    if opened:
+        out_file.close()
 
 def test():
     """uuencode/uudecode main program"""