From cf691935bb1a59bd7ff680b26b0b0040b7e25449 Mon Sep 17 00:00:00 2001
From: Guido van Rossum <guido@python.org>
Date: Fri, 21 Sep 2001 21:06:22 +0000
Subject: reportdiff(): print a "plain diff" style diff.

XXX This should really be a unified diff, but I can't be bothered.
---
 Lib/test/regrtest.py | 34 ++++++++++++++++++++++++++++++----
 1 file changed, 30 insertions(+), 4 deletions(-)

diff --git a/Lib/test/regrtest.py b/Lib/test/regrtest.py
index c8c9167..79ee3b1 100755
--- a/Lib/test/regrtest.py
+++ b/Lib/test/regrtest.py
@@ -351,10 +351,36 @@ def runtest(test, generate, verbose, quiet, testdir = None):
 def reportdiff(expected, output):
     print "*" * 70
     import difflib
-    a = expected.splitlines(1)
-    b = output.splitlines(1)
-    diff = difflib.ndiff(a, b)
-    print ''.join(diff),
+    a = expected.splitlines()
+    b = output.splitlines()
+    sm = difflib.SequenceMatcher(a=a, b=b)
+    tuples = sm.get_opcodes()
+    def pair(x0, x1):
+        x0 += 1
+        if x0 >= x1:
+            return str(x0)
+        else:
+            return "%d,%d" % (x0, x1)
+    for op, a0, a1, b0, b1 in tuples:
+        if op == 'equal':
+            pass
+        elif op == 'delete':
+            print pair(a0, a1) + "d" + pair(b0, b1)
+            for line in a[a0:a1]:
+                print "<", line
+        elif op == 'replace':
+            print pair(a0, a1) + "c" + pair(b0, b1)
+            for line in a[a0:a1]:
+                print "<", line
+            print "---"
+            for line in b[b0:b1]:
+                print ">", line
+        elif op == 'insert':
+            print str(a0) + "a" + pair(b0, b1)
+            for line in b[b0:b1]:
+                print ">", line
+        else:
+            print "get_opcodes() returned bad tuple?!?!", (op, a0, a1, b0, b1)
     print "*" * 70
 
 def findtestdir():
-- 
cgit v0.12

'>tree</a><a href='/oss-git/cpython.git/commit/Lib/copy.py?id=2cefc1efa2fc74da0ec1b79f75639b76ac8e6dfd'>commit</a><a href='/oss-git/cpython.git/diff/Lib/copy.py?id=2cefc1efa2fc74da0ec1b79f75639b76ac8e6dfd'>diff</a><a href='/oss-git/cpython.git/stats/Lib/copy.py'>stats</a></td><td class='form'><form class='right' method='get' action='/oss-git/cpython.git/log/Lib/copy.py'>
<input type='hidden' name='id' value='2cefc1efa2fc74da0ec1b79f75639b76ac8e6dfd'/><select name='qt'>
<option value='grep'>log msg</option>
<option value='author'>author</option>
<option value='committer'>committer</option>
<option value='range'>range</option>
</select>
<input class='txt' type='text' size='10' name='q' value=''/>
<input type='submit' value='search'/>
</form>
</td></tr></table>
<div class='path'>path: <a href='/oss-git/cpython.git/log/?id=2cefc1efa2fc74da0ec1b79f75639b76ac8e6dfd'>root</a>/<a href='/oss-git/cpython.git/log/Lib?id=2cefc1efa2fc74da0ec1b79f75639b76ac8e6dfd'>Lib</a>/<a href='/oss-git/cpython.git/log/Lib/copy.py?id=2cefc1efa2fc74da0ec1b79f75639b76ac8e6dfd'>copy.py</a></div><div class='content'><table class='list nowrap'><tr class='nohover'><th></th><th class='left'>Commit message (<a href='/oss-git/cpython.git/log/Lib/copy.py?id=2cefc1efa2fc74da0ec1b79f75639b76ac8e6dfd&amp;showmsg=1'>Expand</a>)</th><th class='left'>Author</th><th class='left'>Age</th><th class='left'>Files</th><th class='left'>Lines</th></tr>
<tr><td class='commitgraph'>* </td><td><a href='/oss-git/cpython.git/commit/Lib/copy.py?id=32af7549a7cf8f112c44526a28afa6c99e67269c'>Issue #20289: The copy module now uses pickle protocol 4 (PEP 3154) and</a><span class='decoration'></span></td><td>Serhiy Storchaka</td><td><span title='2015-03-24 16:06:42 (GMT)'>2015-03-24</span></td><td>1</td><td>-2/+2</td></tr>
<tr class='nohover'><td class='commitgraph'></td>
<td colspan='5'>
</td></tr>
<tr><td class='commitgraph'>* </td><td><a href='/oss-git/cpython.git/commit/Lib/copy.py?id=4ce5f3f203c1c510bd1eff4d8fffea6198e40b4d'>improve idioms (closes #20642)</a><span class='decoration'></span></td><td>Benjamin Peterson</td><td><span title='2014-05-04 00:22:00 (GMT)'>2014-05-04</span></td><td>1</td><td>-5/+3</td></tr>
<tr class='nohover'><td class='commitgraph'></td>
<td colspan='5'>
</td></tr>
<tr><td class='commitgraph'>* </td><td><a href='/oss-git/cpython.git/commit/Lib/copy.py?id=dc9215f8828b23ed6c294f8e64342a55dcdf1e4c'>Issue #20791: copy.copy() now doesn't make a copy when the input is a bytes o...</a><span class='decoration'></span></td><td>Antoine Pitrou</td><td><span title='2014-02-27 21:14:31 (GMT)'>2014-02-27</span></td><td>1</td><td>-1/+1</td></tr>
<tr class='nohover'><td class='commitgraph'></td>
<td colspan='5'>
</td></tr>
<tr><td class='commitgraph'>* </td><td><a href='/oss-git/cpython.git/commit/Lib/copy.py?id=5c1c3b4f197c57952760be37d77d73669284a607'>Issue #11480: Fixed copy.copy to work with classes with custom metaclasses.</a><span class='decoration'></span></td><td>Alexandre Vassalotti</td><td><span title='2013-12-01 21:25:26 (GMT)'>2013-12-01</span></td><td>1</td><td>-0/+8</td></tr>
<tr class='nohover'><td class='commitgraph'></td>
<td colspan='5'>
</td></tr>
<tr><td class='commitgraph'>* </td><td><a href='/oss-git/cpython.git/commit/Lib/copy.py?id=4dc9c84ed9ad3a22d37abc06e53c450130bba317'>#11572: improvements to copy module tests along with removal of old test suite</a><span class='decoration'></span></td><td>Sandro Tosi</td><td><span title='2011-08-05 21:05:35 (GMT)'>2011-08-05</span></td><td>1</td><td>-65/+0</td></tr>
<tr class='nohover'><td class='commitgraph'></td>
<td colspan='5'>
</td></tr>
<tr><td class='commitgraph'>* </td><td><a href='/oss-git/cpython.git/commit/Lib/copy.py?id=e90ec366fb1f29705f3f6ed970091c5b3fa131a8'>don't memoize objects that are their own copies (closes #12422)</a><span class='decoration'></span></td><td>Benjamin Peterson</td><td><span title='2011-06-27 21:22:46 (GMT)'>2011-06-27</span></td><td>1</td><td>-5/+7</td></tr>
<tr class='nohover'><td class='commitgraph'></td>
<td colspan='5'>
</td></tr>
<tr><td class='commitgraph'>* </td><td><a href='/oss-git/cpython.git/commit/Lib/copy.py?id=d6399d2d19ef665a2893089be12e2214f73b643b'>Fix running the copy module from the command-line (however use{ful,less} it m...</a><span class='decoration'></span></td><td>Antoine Pitrou</td><td><span title='2010-09-04 17:46:44 (GMT)'>2010-09-04</span></td><td>1</td><td>-1/+2</td></tr>
<tr class='nohover'><td class='commitgraph'></td>
<td colspan='5'>
</td></tr>
<tr><td class='commitgraph'>* </td><td><a href='/oss-git/cpython.git/commit/Lib/copy.py?id=3941a8fece7e714583965565795f2986aa203cb1'>Issue #1100562: Fix deep-copying of objects derived from the list and dict ty...</a><span class='decoration'></span></td><td>Antoine Pitrou</td><td><span title='2010-09-04 17:40:21 (GMT)'>2010-09-04</span></td><td>1</td><td>-11/+23</td></tr>
<tr class='nohover'><td class='commitgraph'></td>
<td colspan='5'>
</td></tr>
<tr><td class='commitgraph'>* </td><td><a href='/oss-git/cpython.git/commit/Lib/copy.py?id=1fc0d2b364b144e501615cf82e998beb87733607'>Merged revisions 76571 via svnmerge from</a><span class='decoration'></span></td><td>Antoine Pitrou</td><td><span title='2009-11-28 15:58:27 (GMT)'>2009-11-28</span></td><td>1</td><td>-0/+4</td></tr>
<tr class='nohover'><td class='commitgraph'></td>
<td colspan='5'>
</td></tr>
<tr><td class='commitgraph'>* </td><td><a href='/oss-git/cpython.git/commit/Lib/copy.py?id=6e61006cc2dfa6c07fa84126622685769bac635d'>Merged revisions 72669 via svnmerge from</a><span class='decoration'></span></td><td>Antoine Pitrou</td><td><span title='2009-05-15 17:04:50 (GMT)'>2009-05-15</span></td><td>1</td><td>-1/+3</td></tr>
<tr class='nohover'><td class='commitgraph'></td>
<td colspan='5'>
</td></tr>
<tr><td class='commitgraph'>* </td><td><a href='/oss-git/cpython.git/commit/Lib/copy.py?id=1f2ba4b6dad80f97aeecb5be8f35f44ca792c983'>Rename the repr module to reprlib.</a><span class='decoration'></span></td><td>Alexandre Vassalotti</td><td><span title='2008-05-16 07:12:44 (GMT)'>2008-05-16</span></td><td>1</td><td>-10/+9</td></tr>
<tr class='nohover'><td class='commitgraph'></td>
<td colspan='5'>
</td></tr>
<tr><td class='commitgraph'>* </td><td><a href='/oss-git/cpython.git/commit/Lib/copy.py?id=f7fa63dd55e638d300a8d4a148dcedb402fdb750'>Rename copy_reg module to copyreg.</a><span class='decoration'></span></td><td>Alexandre Vassalotti</td><td><span title='2008-05-11 08:55:36 (GMT)'>2008-05-11</span></td><td>1</td><td>-1/+1</td></tr>
<tr class='nohover'><td class='commitgraph'></td>
<td colspan='5'>
</td></tr>
<tr><td class='commitgraph'>* </td><td><a href='/oss-git/cpython.git/commit/Lib/copy.py?id=cc47b05fe5c66bb2f1e520234039070044dad218'>Merged revisions 61834,61841-61842,61851-61853,61863-61864,61869-61870,61874,...</a><span class='decoration'></span></td><td>Christian Heimes</td><td><span title='2008-03-25 14:56:36 (GMT)'>2008-03-25</span></td><td>1</td><td>-1/+2</td></tr>
<tr class='nohover'><td class='commitgraph'></td>
<td colspan='5'>
</td></tr>
<tr><td class='commitgraph'>* </td><td><a href='/oss-git/cpython.git/commit/Lib/copy.py?id=98297ee7815939b124156e438b22bd652d67b5db'>Merging the py3k-pep3137 branch back into the py3k branch.</a><span class='decoration'></span></td><td>Guido van Rossum</td><td><span title='2007-11-06 21:34:58 (GMT)'>2007-11-06</span></td><td>1</td><td>-1/+1</td></tr>
<tr class='nohover'><td class='commitgraph'></td>
<td colspan='5'>
</td></tr>
<tr><td class='commitgraph'>* </td><td><a href='/oss-git/cpython.git/commit/Lib/copy.py?id=1325790b932c4bab4f8f94f5a36c09f4036ed9f8'>Merged revisions 55795-55816 via svnmerge from</a><span class='decoration'></span></td><td>Guido van Rossum</td><td><span title='2007-06-07 23:15:56 (GMT)'>2007-06-07</span></td><td>1</td><td>-4/+6</td></tr>
<tr class='nohover'><td class='commitgraph'></td>
<td colspan='5'>
</td></tr>
<tr><td class='commitgraph'>* </td><td><a href='/oss-git/cpython.git/commit/Lib/copy.py?id=756f139b976890d5ad3a57cea840a7e8172a7070'>Register a dispatcher for str8. (This makes test_copy.py pass again.)</a><span class='decoration'></span></td><td>Walter Dörwald</td><td><span title='2007-06-07 13:11:04 (GMT)'>2007-06-07</span></td><td>1</td><td>-4/+1</td></tr>
<tr class='nohover'><td class='commitgraph'></td>
<td colspan='5'>
</td></tr>
<tr><td class='commitgraph'>* </td><td><a href='/oss-git/cpython.git/commit/Lib/copy.py?id=805365ee39298f93e433e19ae0dd87c6f782145b'>Merged revisions 55007-55179 via svnmerge from</a><span class='decoration'></span></td><td>Guido van Rossum</td><td><span title='2007-05-07 22:24:25 (GMT)'>2007-05-07</span></td><td>1</td><td>-2/+2</td></tr>
<tr class='nohover'><td class='commitgraph'></td>
<td colspan='5'>
</td></tr>
<tr><td class='commitgraph'>* </td><td><a href='/oss-git/cpython.git/commit/Lib/copy.py?id=ef87d6ed94780fe00250a551031023aeb2898365'>Rip out all the u"..." literals and calls to unicode().</a><span class='decoration'></span></td><td>Guido van Rossum</td><td><span title='2007-05-02 19:09:54 (GMT)'>2007-05-02</span></td><td>1</td><td>-1/+1</td></tr>
<tr class='nohover'><td class='commitgraph'></td>
<td colspan='5'>
</td></tr>
<tr><td class='commitgraph'>* </td><td><a href='/oss-git/cpython.git/commit/Lib/copy.py?id=b69b2e59f69def8fa90ab762ec6b116d0a0e0a29'>Remove duplicate refs to int from int/long unification presumably.  (There mi...</a><span class='decoration'></span></td><td>Neal Norwitz</td><td><span title='2007-02-27 03:41:04 (GMT)'>2007-02-27</span></td><td>1</td><td>-2/+1</td></tr>
<tr class='nohover'><td class='commitgraph'></td>
<td colspan='5'>
</td></tr>
<tr><td class='commitgraph'>* </td><td><a href='/oss-git/cpython.git/commit/Lib/copy.py?id=cc2b0161257495f859200bce0aea3ed7e646feb3'>- PEP 3106: dict.iterkeys(), .iteritems(), .itervalues() are now gone;</a><span class='decoration'></span></td><td>Guido van Rossum</td><td><span title='2007-02-11 06:12:03 (GMT)'>2007-02-11</span></td><td>1</td><td>-3/+3</td></tr>
<tr class='nohover'><td class='commitgraph'></td>
<td colspan='5'>
</td></tr>
<tr><td class='commitgraph'>* </td><td><a href='/oss-git/cpython.git/commit/Lib/copy.py?id=be19ed77ddb047e02fe94d142181062af6d99dcc'>Fix most trivially-findable print statements.</a><span class='decoration'></span></td><td>Guido van Rossum</td><td><span title='2007-02-09 05:37:30 (GMT)'>2007-02-09</span>