Skip to content

Commit a4b42ce

Browse files
Do not throw exception when Config.__init__() failed
Config.__init__() does not always set self._config, which can cause trouble during __del__(). This avoids seemingly spurious and not really helpful exceptions. Fixes #916
1 parent e187843 commit a4b42ce

File tree

1 file changed

+4
-1
lines changed

1 file changed

+4
-1
lines changed

pygit2/config.py

+4-1
Original file line numberDiff line numberDiff line change
@@ -96,7 +96,10 @@ def from_c(cls, repo, ptr):
9696
return config
9797

9898
def __del__(self):
99-
C.git_config_free(self._config)
99+
try:
100+
C.git_config_free(self._config)
101+
except AttributeError:
102+
pass
100103

101104
def _get(self, key):
102105
assert_string(key, "key")

0 commit comments

Comments
 (0)