summaryrefslogtreecommitdiff
path: root/src/engine/SCons/dblite.py
diff options
context:
space:
mode:
authorJörg Frings-Fürst <debian@jff-webhosting.net>2019-07-14 08:35:35 +0200
committerJörg Frings-Fürst <debian@jff-webhosting.net>2019-07-14 08:35:35 +0200
commitb4de7f5943eb16fa393df953e97eb2ba8cc35df1 (patch)
tree20239aec5f6b0ec44acd691ad98e1a4b38957c8b /src/engine/SCons/dblite.py
parent85dbcc01ae3f6b10849aa71faef6946d8e16d55f (diff)
parent697e33ed224b539a42ff68121f7497f5bbf941b2 (diff)
Update upstream source from tag 'upstream/3.0.5'
Update to upstream version '3.0.5' with Debian dir 03c2cf71b97fe65fcfd82c7f4a3862fe2b35614d
Diffstat (limited to 'src/engine/SCons/dblite.py')
-rw-r--r--src/engine/SCons/dblite.py16
1 files changed, 10 insertions, 6 deletions
diff --git a/src/engine/SCons/dblite.py b/src/engine/SCons/dblite.py
index 87a1763..14bd93d 100644
--- a/src/engine/SCons/dblite.py
+++ b/src/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):