summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMichael Käufl <michael-k@users.noreply.github.com>2018-09-10 21:36:40 +0200
committerSebastian Thiel <byronimo@gmail.com>2018-10-21 12:24:21 +0200
commitc49ba433b3ff5960925bd405950aae9306be378b (patch)
tree3bc75b9a7177ef3a97201f2e700dc97b126a6747
parent8fc6563219017354bdfbc1bf62ec3a43ad6febcb (diff)
downloadgitpython-c49ba433b3ff5960925bd405950aae9306be378b.tar.gz
The proper way is return, not raise StopIteration
See PEP 479[1] which is part of Python 3.7[2]. [1]: https://www.python.org/dev/peps/pep-0479/ [2]: https://docs.python.org/3/whatsnew/3.7.html#changes-in-python-behavior
-rw-r--r--git/objects/submodule/base.py2
-rw-r--r--git/repo/base.py15
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