summaryrefslogtreecommitdiffstats
path: root/Lib/packaging/util.py
diff options
context:
space:
mode:
authorVictor Stinner <victor.stinner@haypocalc.com>2011-05-19 13:51:27 (GMT)
committerVictor Stinner <victor.stinner@haypocalc.com>2011-05-19 13:51:27 (GMT)
commit21a9c748aa8698c8201e30a58320d587f6bb7540 (patch)
treeddfcb60a800bc010237ee750a449c4639e5515e3 /Lib/packaging/util.py
parent0e3f3a70760f5ef1c0d1f7baf55046514b6bfbb6 (diff)
downloadcpython-21a9c748aa8698c8201e30a58320d587f6bb7540.zip
cpython-21a9c748aa8698c8201e30a58320d587f6bb7540.tar.gz
cpython-21a9c748aa8698c8201e30a58320d587f6bb7540.tar.bz2
packaging: use with open() instead of try/finally: close
Diffstat (limited to 'Lib/packaging/util.py')
-rw-r--r--Lib/packaging/util.py5
1 files changed, 1 insertions, 4 deletions
diff --git a/Lib/packaging/util.py b/Lib/packaging/util.py
index 486e2da..348e3cd 100644
--- a/Lib/packaging/util.py
+++ b/Lib/packaging/util.py
@@ -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")