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

AUTHORS

Lines changed: 1 addition & 0 deletions
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.

git/util.py

Lines changed: 6 additions & 3 deletions
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)
pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy