Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Commit bbeac6e

Browse files
committed
Use two-argument form of next() and use a return-statement instead of an explicit raise StopIteration
1 parent ae39fbd commit bbeac6e

1 file changed

Lines changed: 2 additions & 5 deletions

File tree

Lib/difflib.py

Lines changed: 2 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1448,10 +1448,7 @@ def _line_iterator():
14481448
# are a concatenation of the first character of each of the 4 lines
14491449
# so we can do some very readable comparisons.
14501450
while len(lines) < 4:
1451-
try:
1452-
lines.append(next(diff_lines_iterator))
1453-
except StopIteration:
1454-
lines.append('X')
1451+
lines.append(next(diff_lines_iterator, 'X'))
14551452
s = ''.join([line[0] for line in lines])
14561453
if s.startswith('X'):
14571454
# When no more lines, pump out any remaining blank lines so the
@@ -1514,7 +1511,7 @@ def _line_iterator():
15141511
num_blanks_to_yield -= 1
15151512
yield ('','\n'),None,True
15161513
if s.startswith('X'):
1517-
raise StopIteration
1514+
return
15181515
else:
15191516
yield from_line,to_line,True
15201517

0 commit comments

Comments
 (0)