summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorCésar Izurieta <cesar@caih.org>2019-04-14 00:24:59 +0200
committerSebastian Thiel <byronimo@gmail.com>2019-07-21 08:45:18 +0800
commitbd86c87c38d58b9ca18241a75c4d28440c7ef150 (patch)
treea894b720caf48ba7f8418e0edf12679a03a79ec6
parente93ffe192427ee2d28a0dd90dbe493e3c54f3eae (diff)
downloadgitpython-bd86c87c38d58b9ca18241a75c4d28440c7ef150.tar.gz
Fix `AttributeError` when searching a remote by name
Running code like `'origin' in git.Repo('path/to/existing/repository').remotes` raises an AttributeError instead of returning a boolean. This commit fixes that behaviour by catching the error when doing an identity match on `IterableList`.
-rw-r--r--AUTHORS1
-rw-r--r--git/util.py9
2 files changed, 7 insertions, 3 deletions
diff --git a/AUTHORS b/AUTHORS
index 5f42f856..a0aa707c 100644
--- a/AUTHORS
+++ b/AUTHORS
@@ -32,5 +32,6 @@ Contributors are:
-A. Jesse Jiryu Davis <jesse _at_ emptysquare.net>
-Steven Whitman <ninloot _at_ gmail.com>
-Stefan Stancu <stefan.stancu _at_ gmail.com>
+-César Izurieta <cesar _at_ caih.org>
Portions derived from other open source works and are clearly marked.
diff --git a/git/util.py b/git/util.py
index 3ba58857..7ca0564e 100644
--- a/git/util.py
+++ b/git/util.py
@@ -864,9 +864,12 @@ class IterableList(list):
def __contains__(self, attr):
# first try identity match for performance
- rval = list.__contains__(self, attr)
- if rval:
- return rval
+ try:
+ rval = list.__contains__(self, attr)
+ if rval:
+ return rval
+ except (AttributeError, TypeError):
+ pass
# END handle match
# otherwise make a full name search