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

@ -350,7 +350,7 @@ def byte_compile(py_files, optimize=0, force=False, prefix=None,
else:
script = open(script_name, "w")
try:
with script:
script.write("""\
from packaging.util import byte_compile
files = [
@ -378,9 +378,6 @@ byte_compile(files, optimize=%r, force=%r,
direct=True)
""" % (optimize, force, prefix, base_dir, verbose))
finally:
script.close()
cmd = [sys.executable, script_name]
if optimize == 1:
cmd.insert(1, "-O")