Kaydet (Commit) f3caca28 authored tarafından Andrew M. Kuchling's avatar Andrew M. Kuchling

Jython compatibility fix: if uu.decode() opened its output file, be sure to

close it.
üst b15f4739
...@@ -115,6 +115,7 @@ def decode(in_file, out_file=None, mode=None, quiet=0): ...@@ -115,6 +115,7 @@ def decode(in_file, out_file=None, mode=None, quiet=0):
# #
# Open the output file # Open the output file
# #
opened = False
if out_file == '-': if out_file == '-':
out_file = sys.stdout out_file = sys.stdout
elif isinstance(out_file, StringType): elif isinstance(out_file, StringType):
...@@ -124,6 +125,7 @@ def decode(in_file, out_file=None, mode=None, quiet=0): ...@@ -124,6 +125,7 @@ def decode(in_file, out_file=None, mode=None, quiet=0):
except AttributeError: except AttributeError:
pass pass
out_file = fp out_file = fp
opened = True
# #
# Main decoding loop # Main decoding loop
# #
...@@ -141,6 +143,8 @@ def decode(in_file, out_file=None, mode=None, quiet=0): ...@@ -141,6 +143,8 @@ def decode(in_file, out_file=None, mode=None, quiet=0):
s = in_file.readline() s = in_file.readline()
if not s: if not s:
raise Error, 'Truncated input file' raise Error, 'Truncated input file'
if opened:
out_file.close()
def test(): def test():
"""uuencode/uudecode main program""" """uuencode/uudecode main program"""
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment