Skip to content
Closed
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 5 additions & 4 deletions Lib/difflib.py
Original file line number Diff line number Diff line change
Expand Up @@ -837,7 +837,7 @@ class Differ:
Compare two sequences of lines; generate the resulting delta.
"""

def __init__(self, linejunk=None, charjunk=None):
def __init__(self, linejunk=None, charjunk=None, autojunk=True):
"""
Construct a text differencer, with optional filters.

Expand All @@ -859,6 +859,7 @@ def __init__(self, linejunk=None, charjunk=None):

self.linejunk = linejunk
self.charjunk = charjunk
self.autojunk = autojunk

def compare(self, a, b):
r"""
Expand Down Expand Up @@ -886,7 +887,7 @@ def compare(self, a, b):
+ emu
"""

cruncher = SequenceMatcher(self.linejunk, a, b)
cruncher = SequenceMatcher(self.linejunk, a, b, self.autojunk)
for tag, alo, ahi, blo, bhi in cruncher.get_opcodes():
if tag == 'replace':
g = self._fancy_replace(a, alo, ahi, b, blo, bhi)
Expand Down Expand Up @@ -1330,7 +1331,7 @@ def decode(s):
for line in lines:
yield line.encode('ascii', 'surrogateescape')

def ndiff(a, b, linejunk=None, charjunk=IS_CHARACTER_JUNK):
def ndiff(a, b, linejunk=None, charjunk=IS_CHARACTER_JUNK, autojunk=True):
r"""
Compare `a` and `b` (lists of strings); return a `Differ`-style delta.

Expand Down Expand Up @@ -1365,7 +1366,7 @@ def ndiff(a, b, linejunk=None, charjunk=IS_CHARACTER_JUNK):
+ tree
+ emu
"""
return Differ(linejunk, charjunk).compare(a, b)
return Differ(linejunk, charjunk, autojunk).compare(a, b)

def _mdiff(fromlines, tolines, context=None, linejunk=None,
charjunk=IS_CHARACTER_JUNK):
Expand Down