packaging: use with open() instead of try/finally: close

This commit is contained in:
Victor Stinner 2011-05-19 15:51:27 +02:00
parent 0e3f3a7076
commit 21a9c748aa
11 changed files with 41 additions and 69 deletions

View file

@ -720,17 +720,15 @@ class EggInfoToDistInfoTestCase(support.TempdirManager,
dir_paths.append(path)
for f in files:
path = os.path.join(tempdir, f)
_f = open(path, 'w')
_f.write(f)
_f.close()
with open(path, 'w') as _f:
_f.write(f)
file_paths.append(path)
record_file = open(record_file_path, 'w')
for fpath in file_paths:
record_file.write(fpath + '\n')
for dpath in dir_paths:
record_file.write(dpath + '\n')
record_file.close()
with open(record_file_path, 'w') as record_file:
for fpath in file_paths:
record_file.write(fpath + '\n')
for dpath in dir_paths:
record_file.write(dpath + '\n')
return (tempdir, record_file_path)