diff options
author | Raymond Hettinger <python@rcn.com> | 2014-08-03 22:49:07 -0700 |
---|---|---|
committer | Raymond Hettinger <python@rcn.com> | 2014-08-03 22:49:07 -0700 |
commit | bbeac6ebd8c760b927326c46dfb9d7201a6b8845 (patch) | |
tree | ebdbdbed0159499fa2e12aebc3d99f8f067b9b9f /Lib/difflib.py | |
parent | ae39fbdd8456db5c5da57d7df7ca565026944c4a (diff) | |
download | cpython-git-bbeac6ebd8c760b927326c46dfb9d7201a6b8845.tar.gz |
Use two-argument form of next() and use a return-statement instead of an explicit raise StopIteration
Diffstat (limited to 'Lib/difflib.py')
-rw-r--r-- | Lib/difflib.py | 7 |
1 files changed, 2 insertions, 5 deletions
diff --git a/Lib/difflib.py b/Lib/difflib.py index 9bc0d0dc01..ae3479d3d8 100644 --- a/Lib/difflib.py +++ b/Lib/difflib.py @@ -1448,10 +1448,7 @@ def _mdiff(fromlines, tolines, context=None, linejunk=None, # are a concatenation of the first character of each of the 4 lines # so we can do some very readable comparisons. while len(lines) < 4: - try: - lines.append(next(diff_lines_iterator)) - except StopIteration: - lines.append('X') + lines.append(next(diff_lines_iterator, 'X')) s = ''.join([line[0] for line in lines]) if s.startswith('X'): # When no more lines, pump out any remaining blank lines so the @@ -1514,7 +1511,7 @@ def _mdiff(fromlines, tolines, context=None, linejunk=None, num_blanks_to_yield -= 1 yield ('','\n'),None,True if s.startswith('X'): - raise StopIteration + return else: yield from_line,to_line,True |