diff options
author | Sebastian Thiel <byronimo@gmail.com> | 2010-05-03 23:20:51 +0200 |
---|---|---|
committer | Sebastian Thiel <byronimo@gmail.com> | 2010-05-04 09:00:23 +0200 |
commit | 22a0289972b365b7912340501b52ca3dd98be289 (patch) | |
tree | 31a1b076153d7ecfbe4349d3562dbadcaff2192e /lib/git/index.py | |
parent | 0d6ceabf5b90e7c0690360fc30774d36644f563c (diff) | |
download | gitpython-22a0289972b365b7912340501b52ca3dd98be289.tar.gz |
Index: handling an AttributeError exception raised in python 2.6.5 and newer if an unset slot is being deleted.
Diffstat (limited to 'lib/git/index.py')
-rw-r--r-- | lib/git/index.py | 15 |
1 files changed, 12 insertions, 3 deletions
diff --git a/lib/git/index.py b/lib/git/index.py index 6f615024..0741d71a 100644 --- a/lib/git/index.py +++ b/lib/git/index.py @@ -248,7 +248,7 @@ def clear_cache(func): """ def clear_cache_if_not_raised(self, *args, **kwargs): rval = func(self, *args, **kwargs) - del(self.entries) + self._delete_entries_cache() return rval # END wrapper method @@ -345,6 +345,15 @@ class IndexFile(LazyMixin, diff.Diffable): """ return self._file_path + def _delete_entries_cache(self): + """Safely clear the entries cache so it can be recreated""" + try: + del(self.entries) + except AttributeError: + # fails in python 2.6.5 with this exception + pass + # END exception handling + @classmethod def _read_entry(cls, stream): """Return: One entry of the given stream""" @@ -774,7 +783,7 @@ class IndexFile(LazyMixin, diff.Diffable): Returns self """ - del(self.entries) + self._delete_entries_cache() # allows to lazily reread on demand return self @@ -937,7 +946,7 @@ class IndexFile(LazyMixin, diff.Diffable): self._flush_stdin_and_wait(proc, ignore_stdout=True) # ignore stdout # force rereading our entries once it is all done - del(self.entries) + self._delete_entries_cache() entries_added.extend(self.entries[(f,0)] for f in added_files) # END path handling |