summaryrefslogtreecommitdiffstats
path: root/git_config.py
diff options
context:
space:
mode:
Diffstat (limited to 'git_config.py')
-rw-r--r--git_config.py14
1 files changed, 10 insertions, 4 deletions
diff --git a/git_config.py b/git_config.py
index 7aad80d2..7e642a4c 100644
--- a/git_config.py
+++ b/git_config.py
@@ -219,7 +219,11 @@ class GitConfig(object):
219 return None 219 return None
220 try: 220 try:
221 Trace(': unpickle %s', self.file) 221 Trace(': unpickle %s', self.file)
222 return cPickle.load(open(self._pickle, 'r')) 222 fd = open(self._pickle, 'rb')
223 try:
224 return cPickle.load(fd)
225 finally:
226 fd.close()
223 except IOError: 227 except IOError:
224 os.remove(self._pickle) 228 os.remove(self._pickle)
225 return None 229 return None
@@ -229,9 +233,11 @@ class GitConfig(object):
229 233
230 def _SavePickle(self, cache): 234 def _SavePickle(self, cache):
231 try: 235 try:
232 cPickle.dump(cache, 236 fd = open(self._pickle, 'wb')
233 open(self._pickle, 'w'), 237 try:
234 cPickle.HIGHEST_PROTOCOL) 238 cPickle.dump(cache, fd, cPickle.HIGHEST_PROTOCOL)
239 finally:
240 fd.close()
235 except IOError: 241 except IOError:
236 os.remove(self._pickle) 242 os.remove(self._pickle)
237 except cPickle.PickleError: 243 except cPickle.PickleError: