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:48:12 +0200
committerJörg Frings-Fürst <debian@jff-webhosting.net>2019-07-12 17:48:12 +0200
commit19712e5025e3cf6a33fccd0738f04e018d55025f (patch)
tree25683461da536e1e7ffee70279780b4f3586142f /engine/SCons/dblite.py
parentcd2ab5002aa2359575088bbc3183a9a91cc50c31 (diff)
New upstream version 3.0.5upstream/3.0.5
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):