aboutsummaryrefslogtreecommitdiff
path: root/mesonbuild/mconf.py
diff options
context:
space:
mode:
authorJussi Pakkanen <jpakkane@gmail.com>2016-09-01 23:12:06 +0300
committerJussi Pakkanen <jpakkane@gmail.com>2016-09-01 23:12:06 +0300
commitcdf0c4f1a945f1262ae604047fd240b25cf44050 (patch)
treeefb861fa017c1f8663b75570fe61fa644c2bd3d0 /mesonbuild/mconf.py
parent389259c229b30d38ec9de503dff965973b24ee26 (diff)
parent859c5e28df90851838aacc4b9ad49d3630e4992a (diff)
downloadmeson-cdf0c4f1a945f1262ae604047fd240b25cf44050.zip
meson-cdf0c4f1a945f1262ae604047fd240b25cf44050.tar.gz
meson-cdf0c4f1a945f1262ae604047fd240b25cf44050.tar.bz2
Merge branch 'QuLogic-context-managers'
Diffstat (limited to 'mesonbuild/mconf.py')
-rw-r--r--mesonbuild/mconf.py9
1 files changed, 6 insertions, 3 deletions
diff --git a/mesonbuild/mconf.py b/mesonbuild/mconf.py
index 4b11c10..afabc62 100644
--- a/mesonbuild/mconf.py
+++ b/mesonbuild/mconf.py
@@ -36,15 +36,18 @@ class Conf:
self.build_file = os.path.join(build_dir, 'meson-private/build.dat')
if not os.path.isfile(self.coredata_file) or not os.path.isfile(self.build_file):
raise ConfException('Directory %s does not seem to be a Meson build directory.' % build_dir)
- self.coredata = pickle.load(open(self.coredata_file, 'rb'))
- self.build = pickle.load(open(self.build_file, 'rb'))
+ with open(self.coredata_file, 'rb') as f:
+ self.coredata = pickle.load(f)
+ with open(self.build_file, 'rb') as f:
+ self.build = pickle.load(f)
if self.coredata.version != coredata.version:
raise ConfException('Version mismatch (%s vs %s)' %
(coredata.version, self.coredata.version))
def save(self):
# Only called if something has changed so overwrite unconditionally.
- pickle.dump(self.coredata, open(self.coredata_file, 'wb'))
+ with open(self.coredata_file, 'wb') as f:
+ pickle.dump(self.coredata, f)
# We don't write the build file because any changes to it
# are erased when Meson is executed the nex time, i.e. the next
# time Ninja is run.