mirror of
https://github.com/python/cpython.git
synced 2025-10-09 16:34:44 +00:00
Use two-argument form of next() and use a return-statement instead of an explicit raise StopIteration
This commit is contained in:
parent
ae39fbdd84
commit
bbeac6ebd8
1 changed files with 2 additions and 5 deletions
|
@ -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
|
# are a concatenation of the first character of each of the 4 lines
|
||||||
# so we can do some very readable comparisons.
|
# so we can do some very readable comparisons.
|
||||||
while len(lines) < 4:
|
while len(lines) < 4:
|
||||||
try:
|
lines.append(next(diff_lines_iterator, 'X'))
|
||||||
lines.append(next(diff_lines_iterator))
|
|
||||||
except StopIteration:
|
|
||||||
lines.append('X')
|
|
||||||
s = ''.join([line[0] for line in lines])
|
s = ''.join([line[0] for line in lines])
|
||||||
if s.startswith('X'):
|
if s.startswith('X'):
|
||||||
# When no more lines, pump out any remaining blank lines so the
|
# 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
|
num_blanks_to_yield -= 1
|
||||||
yield ('','\n'),None,True
|
yield ('','\n'),None,True
|
||||||
if s.startswith('X'):
|
if s.startswith('X'):
|
||||||
raise StopIteration
|
return
|
||||||
else:
|
else:
|
||||||
yield from_line,to_line,True
|
yield from_line,to_line,True
|
||||||
|
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue