diff options
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 |
commit | bee5cef7dbff40734c347da5b93797e8db9103e8 (patch) | |
tree | 06dcc726207cfad3016f2b0f7c365fb9fe5b3cc6 /Lib/distutils/tests/test_msvc9compiler.py | |
parent | afb078dd2673d919ac3733104757c441f256f30f (diff) | |
download | cpython-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.py | 14 |
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) |