diff options
| author | Sebastian Thiel <byronimo@gmail.com> | 2015-01-06 14:05:30 +0100 | 
|---|---|---|
| committer | Sebastian Thiel <byronimo@gmail.com> | 2015-01-06 14:05:30 +0100 | 
| commit | a05e49d2419d65c59c65adf5cd8c05f276550e1d (patch) | |
| tree | 62d8284dbccfee635babe9c46ad5a059f5da0bde /git/config.py | |
| parent | 60e54133aa1105a1270f0a42e74813f75cd2dc46 (diff) | |
| download | gitpython-a05e49d2419d65c59c65adf5cd8c05f276550e1d.tar.gz | |
test_repo works
Diffstat (limited to 'git/config.py')
| -rw-r--r-- | git/config.py | 14 | 
1 files changed, 12 insertions, 2 deletions
| diff --git a/git/config.py b/git/config.py index 96991b84..c7e8b7ac 100644 --- a/git/config.py +++ b/git/config.py @@ -103,8 +103,7 @@ class SectionConstraint(object):          # Yes, for some reason, we have to call it explicitly for it to work in PY3 !          # Apparently __del__ doesn't get call anymore if refcount becomes 0          # Ridiculous ... . -        self._config.__del__() -        # del self._config +        self._config.release()      def __getattr__(self, attr):          if attr in self._valid_attrs_: @@ -121,6 +120,10 @@ class SectionConstraint(object):          """return: Configparser instance we constrain"""          return self._config +    def release(self): +        """Equivalent to GitConfigParser.release(), which is called on our underlying parser instance""" +        return self._config.release() +  class GitConfigParser(with_metaclass(MetaParserBuilder, cp.RawConfigParser, object)): @@ -198,6 +201,13 @@ class GitConfigParser(with_metaclass(MetaParserBuilder, cp.RawConfigParser, obje      def __del__(self):          """Write pending changes if required and release locks""" +        # NOTE: only consistent in PY2 +        self.release() + +    def release(self): +        """Flush changes and release the configuration write lock. This instance must not be used anymore afterwards. +        In Python 3, it's required to explicitly release locks and flush changes, as __del__ is not called  +        deterministically anymore."""          # checking for the lock here makes sure we do not raise during write()          # in case an invalid parser was created who could not get a lock          if self.read_only or (self._lock and not self._lock._has_lock()): | 
