mirror of
https://github.com/python/cpython.git
synced 2025-07-23 11:15:24 +00:00
Always close files in distutils code and tests (#10252).
This commit is contained in:
parent
afb078dd26
commit
bee5cef7db
24 changed files with 261 additions and 171 deletions
|
@ -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)
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue