summaryrefslogtreecommitdiff
path: root/Lib/distutils/tests/test_msvc9compiler.py
diff options
context:
space:
mode:
authorÉric Araujo <merwok@netwok.org>2010-11-05 23:51:56 +0000
committerÉric Araujo <merwok@netwok.org>2010-11-05 23:51:56 +0000
commitbee5cef7dbff40734c347da5b93797e8db9103e8 (patch)
tree06dcc726207cfad3016f2b0f7c365fb9fe5b3cc6 /Lib/distutils/tests/test_msvc9compiler.py
parentafb078dd2673d919ac3733104757c441f256f30f (diff)
downloadcpython-git-bee5cef7dbff40734c347da5b93797e8db9103e8.tar.gz
Always close files in distutils code and tests (#10252).
Diffstat (limited to 'Lib/distutils/tests/test_msvc9compiler.py')
-rw-r--r--Lib/distutils/tests/test_msvc9compiler.py14
1 files changed, 9 insertions, 5 deletions
diff --git a/Lib/distutils/tests/test_msvc9compiler.py b/Lib/distutils/tests/test_msvc9compiler.py
index f1da843fab..40cb8be6d1 100644
--- a/Lib/distutils/tests/test_msvc9compiler.py
+++ b/Lib/distutils/tests/test_msvc9compiler.py
@@ -113,17 +113,21 @@ class msvc9compilerTestCase(support.TempdirManager,
tempdir = self.mkdtemp()
manifest = os.path.join(tempdir, 'manifest')
f = open(manifest, 'w')
- f.write(_MANIFEST)
- f.close()
+ try:
+ f.write(_MANIFEST)
+ finally:
+ f.close()
compiler = MSVCCompiler()
compiler._remove_visual_c_ref(manifest)
# see what we got
f = open(manifest)
- # removing trailing spaces
- content = '\n'.join([line.rstrip() for line in f.readlines()])
- f.close()
+ try:
+ # removing trailing spaces
+ content = '\n'.join([line.rstrip() for line in f.readlines()])
+ finally:
+ f.close()
# makes sure the manifest was properly cleaned
self.assertEquals(content, _CLEANED_MANIFEST)