diff options
-rw-r--r-- | git/objects/submodule/base.py | 2 | ||||
-rw-r--r-- | git/repo/base.py | 15 |
2 files changed, 13 insertions, 4 deletions
diff --git a/git/objects/submodule/base.py b/git/objects/submodule/base.py index f37da34a..446c88fc 100644 --- a/git/objects/submodule/base.py +++ b/git/objects/submodule/base.py @@ -1160,7 +1160,7 @@ class Submodule(IndexObject, Iterable, Traversable): try: parser = cls._config_parser(repo, pc, read_only=True) except IOError: - raise StopIteration + return # END handle empty iterator rt = pc.tree # root tree diff --git a/git/repo/base.py b/git/repo/base.py index 125ab802..3c5d6854 100644 --- a/git/repo/base.py +++ b/git/repo/base.py @@ -714,7 +714,10 @@ class Repo(object): stream = (line for line in data.split(b'\n') if line) while True: - line = next(stream) # when exhausted, causes a StopIteration, terminating this function + try: + line = next(stream) # when exhausted, causes a StopIteration, terminating this function + except StopIteration: + return hexsha, orig_lineno, lineno, num_lines = line.split() lineno = int(lineno) num_lines = int(num_lines) @@ -724,7 +727,10 @@ class Repo(object): # for this commit props = {} while True: - line = next(stream) + try: + line = next(stream) + except StopIteration: + return if line == b'boundary': # "boundary" indicates a root commit and occurs # instead of the "previous" tag @@ -749,7 +755,10 @@ class Repo(object): # Discard all lines until we find "filename" which is # guaranteed to be the last line while True: - line = next(stream) # will fail if we reach the EOF unexpectedly + try: + line = next(stream) # will fail if we reach the EOF unexpectedly + except StopIteration: + return tag, value = line.split(b' ', 1) if tag == b'filename': orig_filename = value |