[Python-checkins] r76468 - in python/branches/release26-maint: Lib/difflib.py Lib/test/test_difflib.py Misc/NEWS

senthil.kumaran python-checkins at python.org
Mon Nov 23 19:54:34 CET 2009


Author: senthil.kumaran
Date: Mon Nov 23 19:54:33 2009
New Revision: 76468
Log:
Merged revisions 76464 via svnmerge from 
svn+ssh://pythondev@svn.python.org/python/trunk
........
 r76464 | senthil.kumaran | 2009年11月24日 00:11:31 +0530 (2009年11月24日) | 4 lines
 
 Fix for issue1488943 - difflib.Differ() doesn't always add hints for tab
 characters.
........
Modified:
 python/branches/release26-maint/ (props changed)
 python/branches/release26-maint/Lib/difflib.py
 python/branches/release26-maint/Lib/test/test_difflib.py
 python/branches/release26-maint/Misc/NEWS
Modified: python/branches/release26-maint/Lib/difflib.py
==============================================================================
--- python/branches/release26-maint/Lib/difflib.py	(original)
+++ python/branches/release26-maint/Lib/difflib.py	Mon Nov 23 19:54:33 2009
@@ -1061,20 +1061,21 @@
 Example:
 
 >>> d = Differ()
- >>> results = d._qformat('\tabcDefghiJkl\n', '\t\tabcdefGhijkl\n',
- ... ' ^ ^ ^ ', '+ ^ ^ ^ ')
+ >>> results = d._qformat('\tabcDefghiJkl\n', '\tabcdefGhijkl\n',
+ ... ' ^ ^ ^ ', ' ^ ^ ^ ')
 >>> for line in results: print repr(line)
 ...
 '- \tabcDefghiJkl\n'
 '? \t ^ ^ ^\n'
- '+ \t\tabcdefGhijkl\n'
- '? \t ^ ^ ^\n'
+ '+ \tabcdefGhijkl\n'
+ '? \t ^ ^ ^\n'
 """
 
 # Can hurt, but will probably help most of the time.
 common = min(_count_leading(aline, "\t"),
 _count_leading(bline, "\t"))
 common = min(common, _count_leading(atags[:common], " "))
+ common = min(common, _count_leading(btags[:common], " "))
 atags = atags[common:].rstrip()
 btags = btags[common:].rstrip()
 
Modified: python/branches/release26-maint/Lib/test/test_difflib.py
==============================================================================
--- python/branches/release26-maint/Lib/test/test_difflib.py	(original)
+++ python/branches/release26-maint/Lib/test/test_difflib.py	Mon Nov 23 19:54:33 2009
@@ -20,6 +20,14 @@
 diff_gen = difflib.unified_diff([], [])
 self.assertRaises(StopIteration, diff_gen.next)
 
+ 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 = """
 1. Beautiful is beTTer than ugly.
 2. Explicit is better than implicit.
Modified: python/branches/release26-maint/Misc/NEWS
==============================================================================
--- python/branches/release26-maint/Misc/NEWS	(original)
+++ python/branches/release26-maint/Misc/NEWS	Mon Nov 23 19:54:33 2009
@@ -258,6 +258,8 @@
 Library
 -------
 
+- Issue #1488943: difflib.Differ() doesn't always add hints for tab characters
+
 - Issue #5037: Proxy the __unicode__ special method instead to __unicode__
 instead of __str__.
 


More information about the Python-checkins mailing list

AltStyle によって変換されたページ (->オリジナル) /