summaryrefslogtreecommitdiff
path: root/engine/SCons/dblite.py
diff options
context:
space:
mode:
authorJörg Frings-Fürst <debian@jff-webhosting.net>2019-07-12 17:52:28 +0200
committerJörg Frings-Fürst <debian@jff-webhosting.net>2019-07-12 17:52:28 +0200
commit81fada2b46636cbd118cc86ca85fa23966a4f88c (patch)
treeb7466cd11e81e45289ba0b36f5c73281f19e1112 /engine/SCons/dblite.py
parent2fb368b8751637ffa010e5e4f79e2dda6adc6038 (diff)
parent7cff8ecb55b0eee07bf8c52ec5b3ea5c156bcbad (diff)
Merge branch 'feature/upstream' into develop
Diffstat (limited to 'engine/SCons/dblite.py')
-rw-r--r--engine/SCons/dblite.py16
1 files changed, 10 insertions, 6 deletions
diff --git a/engine/SCons/dblite.py b/engine/SCons/dblite.py
index 87a1763..14bd93d 100644
--- a/engine/SCons/dblite.py
+++ b/engine/SCons/dblite.py
@@ -75,7 +75,8 @@ class dblite(object):
def __init__(self, file_base_name, flag, mode):
assert flag in (None, "r", "w", "c", "n")
- if (flag is None): flag = "r"
+ if flag is None:
+ flag = "r"
base, ext = os.path.splitext(file_base_name)
if ext == dblite_suffix:
@@ -106,17 +107,20 @@ class dblite(object):
self._chown_to = -1 # don't chown
self._chgrp_to = -1 # don't chgrp
- if (self._flag == "n"):
- self._open(self._file_name, "wb", self._mode)
+ if self._flag == "n":
+ with self._open(self._file_name, "wb", self._mode):
+ pass # just make sure it exists
else:
try:
f = self._open(self._file_name, "rb")
except IOError as e:
- if (self._flag != "c"):
+ if self._flag != "c":
raise e
- self._open(self._file_name, "wb", self._mode)
+ with self._open(self._file_name, "wb", self._mode):
+ pass # just make sure it exists
else:
p = f.read()
+ f.close()
if len(p) > 0:
try:
if bytes is not str:
@@ -132,7 +136,7 @@ class dblite(object):
corruption_warning(self._file_name)
def close(self):
- if (self._needs_sync):
+ if self._needs_sync:
self.sync()
def __del__(self):