Skip to content

Commit f3caca2

Browse files
committed
Jython compatibility fix: if uu.decode() opened its output file, be sure to
close it.
1 parent b15f473 commit f3caca2

File tree

1 file changed

+4
-0
lines changed

1 file changed

+4
-0
lines changed

Lib/uu.py

+4
Original file line numberDiff line numberDiff line change
@@ -115,6 +115,7 @@ def decode(in_file, out_file=None, mode=None, quiet=0):
115115
#
116116
# Open the output file
117117
#
118+
opened = False
118119
if out_file == '-':
119120
out_file = sys.stdout
120121
elif isinstance(out_file, StringType):
@@ -124,6 +125,7 @@ def decode(in_file, out_file=None, mode=None, quiet=0):
124125
except AttributeError:
125126
pass
126127
out_file = fp
128+
opened = True
127129
#
128130
# Main decoding loop
129131
#
@@ -141,6 +143,8 @@ def decode(in_file, out_file=None, mode=None, quiet=0):
141143
s = in_file.readline()
142144
if not s:
143145
raise Error, 'Truncated input file'
146+
if opened:
147+
out_file.close()
144148

145149
def test():
146150
"""uuencode/uudecode main program"""

0 commit comments

Comments
 (0)