As string is iterable, changed to isinstance check · gitpython-developers/GitPython@d759e17 · GitHub
Skip to content

Commit d759e17

Browse files
MarcelBeiningByron
authored andcommitted
As string is iterable, changed to isinstance check
test now works
1 parent 1fa1ce2 commit d759e17

4 files changed

Lines changed: 14 additions & 14 deletions

File tree

.gitignore

Lines changed: 2 additions & 0 deletions

.gitmodules

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,3 @@
1-
[submodule "gitdb"]
2-
url = https://github.com/gitpython-developers/gitdb.git
3-
path = git/ext/gitdb
1+
[submodule "gitdb"]
2+
url = https://github.com/gitpython-developers/gitdb.git
3+
path = git/ext/gitdb

git/index/base.py

Lines changed: 4 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -569,10 +569,8 @@ def _preprocess_add_items(self, items):
569569
""" Split the items into two lists of path strings and BaseEntries. """
570570
paths = []
571571
entries = []
572-
# check if is iterable, else put in list
573-
try:
574-
test_item = iter(items)
575-
except TypeError:
572+
# if it is a string put in list
573+
if isinstance(items, str):
576574
items = [items]
577575

578576
for item in items:
@@ -806,10 +804,8 @@ def _items_to_rela_paths(self, items):
806804
"""Returns a list of repo-relative paths from the given items which
807805
may be absolute or relative paths, entries or blobs"""
808806
paths = []
809-
# check if is iterable, else put in list
810-
try:
811-
test_item = iter(items)
812-
except TypeError:
807+
# if string put in list
808+
if isinstance(items, str):
813809
items = [items]
814810

815811
for item in items:

git/test/test_index.py

Lines changed: 5 additions & 3 deletions

0 commit comments

Comments
 (0)