summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorKostis Anagnostopoulos <ankostis@gmail.com>2016-10-03 00:37:37 +0200
committerKostis Anagnostopoulos <ankostis@gmail.com>2016-10-03 00:37:37 +0200
commit8a01ec439e19df83a2ff17d198118bd5a31c488b (patch)
tree5bfd7b1f02495ca82e9d7d0fd0103c642bb684c1
parentf48ef3177bbee78940579d86d1db9bb30fb0798d (diff)
downloadgitpython-8a01ec439e19df83a2ff17d198118bd5a31c488b.tar.gz
FIX config-lock release early regression caused by #519
+ Regression introduced in d84b960982b, by a wrong comment interpretation.
-rw-r--r--git/config.py21
1 files changed, 8 insertions, 13 deletions
diff --git a/git/config.py b/git/config.py
index b342410c..3c6a32eb 100644
--- a/git/config.py
+++ b/git/config.py
@@ -479,20 +479,15 @@ class GitConfigParser(with_metaclass(MetaParserBuilder, cp.RawConfigParser, obje
is_file_lock = isinstance(fp, string_types + (FileType, ))
if is_file_lock:
self._lock._obtain_lock()
- try:
- if not hasattr(fp, "seek"):
- with open(self._file_or_files, "wb") as fp:
- self._write(fp)
- else:
- fp.seek(0)
- # make sure we do not overwrite into an existing file
- if hasattr(fp, 'truncate'):
- fp.truncate()
+ if not hasattr(fp, "seek"):
+ with open(self._file_or_files, "wb") as fp:
self._write(fp)
- finally:
- # we release the lock - it will not vanish automatically in PY3.5+
- if is_file_lock:
- self._lock._release_lock()
+ else:
+ fp.seek(0)
+ # make sure we do not overwrite into an existing file
+ if hasattr(fp, 'truncate'):
+ fp.truncate()
+ self._write(fp)
def _assure_writable(self, method_name):
if self.read_only: