From 8a01ec439e19df83a2ff17d198118bd5a31c488b Mon Sep 17 00:00:00 2001 From: Kostis Anagnostopoulos Date: Mon, 3 Oct 2016 00:37:37 +0200 Subject: FIX config-lock release early regression caused by #519 + Regression introduced in d84b960982b, by a wrong comment interpretation. --- git/config.py | 21 ++++++++------------- 1 file 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: -- cgit v1.2.1