summaryrefslogtreecommitdiffstats
path: root/Lib/distutils/file_util.py
diff options
context:
space:
mode:
Diffstat (limited to 'Lib/distutils/file_util.py')
-rw-r--r--Lib/distutils/file_util.py8
1 files changed, 5 insertions, 3 deletions
diff --git a/Lib/distutils/file_util.py b/Lib/distutils/file_util.py
index 65aa7e0..c36e712 100644
--- a/Lib/distutils/file_util.py
+++ b/Lib/distutils/file_util.py
@@ -234,6 +234,8 @@ def write_file (filename, contents):
sequence of strings without line terminators) to it.
"""
f = open(filename, "w")
- for line in contents:
- f.write(line + "\n")
- f.close()
+ try:
+ for line in contents:
+ f.write(line + "\n")
+ finally:
+ f.close()