Merged revisions 76469 via svnmerge from
svn+ssh://pythondev@svn.python.org/python/branches/py3k ................ r76469 | senthil.kumaran | 2009-11-24 00:32:52 +0530 (Tue, 24 Nov 2009) | 10 lines Merged revisions 76464 via svnmerge from svn+ssh://pythondev@svn.python.org/python/trunk ........ r76464 | senthil.kumaran | 2009-11-24 00:11:31 +0530 (Tue, 24 Nov 2009) | 4 lines Fix for issue1488943 - difflib.Differ() doesn't always add hints for tab characters. ........ ................
This commit is contained in:
parent
eb0146858b
commit
d884f8a9c4
@ -1060,20 +1060,21 @@ class Differ:
|
|||||||
Example:
|
Example:
|
||||||
|
|
||||||
>>> d = Differ()
|
>>> d = Differ()
|
||||||
>>> results = d._qformat('\tabcDefghiJkl\n', '\t\tabcdefGhijkl\n',
|
>>> results = d._qformat('\tabcDefghiJkl\n', '\tabcdefGhijkl\n',
|
||||||
... ' ^ ^ ^ ', '+ ^ ^ ^ ')
|
... ' ^ ^ ^ ', ' ^ ^ ^ ')
|
||||||
>>> for line in results: print(repr(line))
|
>>> for line in results: print(repr(line))
|
||||||
...
|
...
|
||||||
'- \tabcDefghiJkl\n'
|
'- \tabcDefghiJkl\n'
|
||||||
'? \t ^ ^ ^\n'
|
'? \t ^ ^ ^\n'
|
||||||
'+ \t\tabcdefGhijkl\n'
|
'+ \tabcdefGhijkl\n'
|
||||||
'? \t ^ ^ ^\n'
|
'? \t ^ ^ ^\n'
|
||||||
"""
|
"""
|
||||||
|
|
||||||
# Can hurt, but will probably help most of the time.
|
# Can hurt, but will probably help most of the time.
|
||||||
common = min(_count_leading(aline, "\t"),
|
common = min(_count_leading(aline, "\t"),
|
||||||
_count_leading(bline, "\t"))
|
_count_leading(bline, "\t"))
|
||||||
common = min(common, _count_leading(atags[:common], " "))
|
common = min(common, _count_leading(atags[:common], " "))
|
||||||
|
common = min(common, _count_leading(btags[:common], " "))
|
||||||
atags = atags[common:].rstrip()
|
atags = atags[common:].rstrip()
|
||||||
btags = btags[common:].rstrip()
|
btags = btags[common:].rstrip()
|
||||||
|
|
||||||
|
@ -20,6 +20,14 @@ class TestSFbugs(unittest.TestCase):
|
|||||||
diff_gen = difflib.unified_diff([], [])
|
diff_gen = difflib.unified_diff([], [])
|
||||||
self.assertRaises(StopIteration, next, diff_gen)
|
self.assertRaises(StopIteration, next, diff_gen)
|
||||||
|
|
||||||
|
def test_added_tab_hint(self):
|
||||||
|
# Check fix for bug #1488943
|
||||||
|
diff = list(difflib.Differ().compare(["\tI am a buggy"],["\t\tI am a bug"]))
|
||||||
|
self.assertEqual("- \tI am a buggy", diff[0])
|
||||||
|
self.assertEqual("? --\n", diff[1])
|
||||||
|
self.assertEqual("+ \t\tI am a bug", diff[2])
|
||||||
|
self.assertEqual("? +\n", diff[3])
|
||||||
|
|
||||||
patch914575_from1 = """
|
patch914575_from1 = """
|
||||||
1. Beautiful is beTTer than ugly.
|
1. Beautiful is beTTer than ugly.
|
||||||
2. Explicit is better than implicit.
|
2. Explicit is better than implicit.
|
||||||
|
@ -49,6 +49,8 @@ Core and Builtins
|
|||||||
Library
|
Library
|
||||||
-------
|
-------
|
||||||
|
|
||||||
|
- Issue #1488943: difflib.Differ() doesn't always add hints for tab characters
|
||||||
|
|
||||||
- Issue #7354: distutils.tests.test_msvc9compiler - dragfullwindows can
|
- Issue #7354: distutils.tests.test_msvc9compiler - dragfullwindows can
|
||||||
be 2.
|
be 2.
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user