diff options
author | Jörg Frings-Fürst <debian@jff-webhosting.net> | 2019-08-11 12:17:57 +0200 |
---|---|---|
committer | Jörg Frings-Fürst <debian@jff-webhosting.net> | 2019-08-11 12:17:57 +0200 |
commit | c8ea3b672655ddab746a7aea5a50217057b02b9e (patch) | |
tree | 01a0e712f4cf32c7140cf1a4ae14db4da4202253 /engine/SCons/dblite.py | |
parent | ca7be46fc0013fc037a045b6d4df73776461e821 (diff) | |
parent | f6c9bffb15e04ea412db4df22a3851448221b85a (diff) |
mergedebian/3.1.1-1
Diffstat (limited to 'engine/SCons/dblite.py')
-rw-r--r-- | engine/SCons/dblite.py | 16 |
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): |