summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorAndrew M. Kuchling <amk@amk.ca>2006-11-19 19:00:04 (GMT)
committerAndrew M. Kuchling <amk@amk.ca>2006-11-19 19:00:04 (GMT)
commit8cca0b7db27e7665ea35099f34dfb8497250f725 (patch)
tree497f712ad85da4b2ab99f86de0ebeafb420dc181
parentf42837c899e930fcf7ffe8fd76483073049b7305 (diff)
downloadcpython-8cca0b7db27e7665ea35099f34dfb8497250f725.zip
cpython-8cca0b7db27e7665ea35099f34dfb8497250f725.tar.gz
cpython-8cca0b7db27e7665ea35099f34dfb8497250f725.tar.bz2
Jython compatibility fix: if uu.decode() opened its output file, be sure to close it. (Need to forward-port this.)
-rwxr-xr-xLib/uu.py4
1 files changed, 4 insertions, 0 deletions
diff --git a/Lib/uu.py b/Lib/uu.py
index 2ee336c..310b3f1 100755
--- 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"""