diff options
author | Michael Käufl <michael-k@users.noreply.github.com> | 2018-09-10 21:36:40 +0200 |
---|---|---|
committer | Sebastian Thiel <byronimo@gmail.com> | 2018-10-21 12:24:21 +0200 |
commit | c49ba433b3ff5960925bd405950aae9306be378b (patch) | |
tree | 3bc75b9a7177ef3a97201f2e700dc97b126a6747 /git/repo/base.py | |
parent | 8fc6563219017354bdfbc1bf62ec3a43ad6febcb (diff) | |
download | gitpython-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
Diffstat (limited to 'git/repo/base.py')
-rw-r--r-- | git/repo/base.py | 15 |
1 files changed, 12 insertions, 3 deletions
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 |