mirror of
https://github.com/python/cpython.git
synced 2025-07-24 11:44:31 +00:00
packaging: use with open() instead of try/finally: close
This commit is contained in:
parent
0e3f3a7076
commit
21a9c748aa
11 changed files with 41 additions and 69 deletions
|
@ -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")
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue