mirror of
https://github.com/python/cpython.git
synced 2025-07-07 19:35:27 +00:00
bpo-33224: PEP 479 fix for difflib.mdiff() (GH-6381)
This commit is contained in:
parent
7286dbd8b2
commit
01b731fc2b
3 changed files with 22 additions and 8 deletions
|
@ -1634,14 +1634,18 @@ def _mdiff(fromlines, tolines, context=None, linejunk=None,
|
|||
lines_to_write -= 1
|
||||
# Now yield the context lines after the change
|
||||
lines_to_write = context-1
|
||||
while(lines_to_write):
|
||||
from_line, to_line, found_diff = next(line_pair_iterator)
|
||||
# If another change within the context, extend the context
|
||||
if found_diff:
|
||||
lines_to_write = context-1
|
||||
else:
|
||||
lines_to_write -= 1
|
||||
yield from_line, to_line, found_diff
|
||||
try:
|
||||
while(lines_to_write):
|
||||
from_line, to_line, found_diff = next(line_pair_iterator)
|
||||
# If another change within the context, extend the context
|
||||
if found_diff:
|
||||
lines_to_write = context-1
|
||||
else:
|
||||
lines_to_write -= 1
|
||||
yield from_line, to_line, found_diff
|
||||
except StopIteration:
|
||||
# Catch exception from next() and return normally
|
||||
return
|
||||
|
||||
|
||||
_file_template = """
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue