aboutsummaryrefslogtreecommitdiff
path: root/mesonbuild/mintro.py
diff options
context:
space:
mode:
authorElliott Sales de Andrade <quantum.analyst@gmail.com>2016-08-24 19:29:11 -0400
committerElliott Sales de Andrade <quantum.analyst@gmail.com>2016-08-27 18:29:55 -0400
commit4c71695e41a50dda3199d26ed7aedbaaf3150768 (patch)
tree8bd499a2a113c3da5c1dee8ed29f4b3c69d27dd7 /mesonbuild/mintro.py
parent7830cb61c39fbaf57933ac403dcdf5007667d87d (diff)
downloadmeson-4c71695e41a50dda3199d26ed7aedbaaf3150768.zip
meson-4c71695e41a50dda3199d26ed7aedbaaf3150768.tar.gz
meson-4c71695e41a50dda3199d26ed7aedbaaf3150768.tar.bz2
Use context manager for file I/O.
There are a few cases where a context manager cannot be used, such as the logger.
Diffstat (limited to 'mesonbuild/mintro.py')
-rw-r--r--mesonbuild/mintro.py12
1 files changed, 8 insertions, 4 deletions
diff --git a/mesonbuild/mintro.py b/mesonbuild/mintro.py
index 629b0fc..2086c37 100644
--- a/mesonbuild/mintro.py
+++ b/mesonbuild/mintro.py
@@ -177,10 +177,14 @@ def run(args):
buildfile = os.path.join(bdir, 'meson-private/build.dat')
testfile = os.path.join(bdir, 'meson-private/meson_test_setup.dat')
benchmarkfile = os.path.join(bdir, 'meson-private/meson_benchmark_setup.dat')
- coredata = pickle.load(open(corefile, 'rb'))
- builddata = pickle.load(open(buildfile, 'rb'))
- testdata = pickle.load(open(testfile, 'rb'))
- benchmarkdata = pickle.load(open(benchmarkfile, 'rb'))
+ with open(corefile, 'rb') as f:
+ coredata = pickle.load(f)
+ with open(buildfile, 'rb') as f:
+ builddata = pickle.load(f)
+ with open(testfile, 'rb') as f:
+ testdata = pickle.load(f)
+ with open(benchmarkfile, 'rb') as f:
+ benchmarkdata = pickle.load(f)
if options.list_targets:
list_targets(coredata, builddata)
elif options.target_files is not None: