]> git.ipfire.org Git - thirdparty/Python/cpython.git/commitdiff
Use two-argument form of next() and use a return-statement instead of an explicit...
authorRaymond Hettinger <python@rcn.com>
Mon, 4 Aug 2014 05:49:07 +0000 (22:49 -0700)
committerRaymond Hettinger <python@rcn.com>
Mon, 4 Aug 2014 05:49:07 +0000 (22:49 -0700)
Lib/difflib.py

index 9bc0d0dc01e2434aba7ebf8d11824898a782b60d..ae3479d3d85e00cb839cd9b50e1dda90e995584f 100644 (file)
@@ -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