Skip to content

Commit bd86c87

Browse files
cesarizuByron
authored andcommitted
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`.
1 parent e93ffe1 commit bd86c87

File tree

2 files changed

+7
-3
lines changed

2 files changed

+7
-3
lines changed

Diff for: AUTHORS

+1
Original file line numberDiff line numberDiff line change
@@ -32,5 +32,6 @@ Contributors are:
3232
-A. Jesse Jiryu Davis <jesse _at_ emptysquare.net>
3333
-Steven Whitman <ninloot _at_ gmail.com>
3434
-Stefan Stancu <stefan.stancu _at_ gmail.com>
35+
-César Izurieta <cesar _at_ caih.org>
3536

3637
Portions derived from other open source works and are clearly marked.

Diff for: git/util.py

+6-3
Original file line numberDiff line numberDiff line change
@@ -864,9 +864,12 @@ def __init__(self, id_attr, prefix=''):
864864

865865
def __contains__(self, attr):
866866
# first try identity match for performance
867-
rval = list.__contains__(self, attr)
868-
if rval:
869-
return rval
867+
try:
868+
rval = list.__contains__(self, attr)
869+
if rval:
870+
return rval
871+
except (AttributeError, TypeError):
872+
pass
870873
# END handle match
871874

872875
# otherwise make a full name search

0 commit comments

Comments
 (0)