From 99482ae58a74e236fb40b65c267163a5690f39e1 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Ulrik=20Sj=C3=B6lin?= Date: Fri, 29 Oct 2010 08:23:30 -0700 Subject: [PATCH] Only delete corrupt pickle config files if they exist os.remove() raises OSError if the file being removed doesn't exist. Check before calling to ensure we don't raise a useless exception on an already deleted file. Change-Id: I44c1c7dd97a47fcab8afb6c18fdf179158b6dab7 Signed-off-by: Shawn O. Pearce --- git_config.py | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/git_config.py b/git_config.py index 138470c5..8e3dfb1b 100644 --- a/git_config.py +++ b/git_config.py @@ -257,9 +257,11 @@ class GitConfig(object): finally: fd.close() except IOError: - os.remove(self._pickle) + if os.path.exists(self._pickle): + os.remove(self._pickle) except cPickle.PickleError: - os.remove(self._pickle) + if os.path.exists(self._pickle): + os.remove(self._pickle) def _ReadGit(self): """