Skip to content

Commit f5a77a1

Browse files
authored
Update difflib.py from 3.13.5 (#6067)
1 parent a58d582 commit f5a77a1

File tree

3 files changed

+22
-2
lines changed

3 files changed

+22
-2
lines changed

Lib/difflib.py

Lines changed: 20 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1200,6 +1200,25 @@ def context_diff(a, b, fromfile='', tofile='',
12001200
strings for 'fromfile', 'tofile', 'fromfiledate', and 'tofiledate'.
12011201
The modification times are normally expressed in the ISO 8601 format.
12021202
If not specified, the strings default to blanks.
1203+
1204+
Example:
1205+
1206+
>>> print(''.join(context_diff('one\ntwo\nthree\nfour\n'.splitlines(True),
1207+
... 'zero\none\ntree\nfour\n'.splitlines(True), 'Original', 'Current')),
1208+
... end="")
1209+
*** Original
1210+
--- Current
1211+
***************
1212+
*** 1,4 ****
1213+
one
1214+
! two
1215+
! three
1216+
four
1217+
--- 1,4 ----
1218+
+ zero
1219+
one
1220+
! tree
1221+
four
12031222
"""
12041223

12051224
_check_types(a, b, fromfile, tofile, fromfiledate, tofiledate, lineterm)
@@ -1609,7 +1628,7 @@ def _line_pair_iterator():
16091628
</html>"""
16101629

16111630
_styles = """
1612-
table.diff {font-family:Courier; border:medium;}
1631+
table.diff {font-family: Menlo, Consolas, Monaco, Liberation Mono, Lucida Console, monospace; border:medium}
16131632
.diff_header {background-color:#e0e0e0}
16141633
td.diff_header {text-align:right}
16151634
.diff_next {background-color:#c0c0c0}

Lib/test/test_difflib.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -186,6 +186,7 @@ def test_mdiff_catch_stop_iteration(self):
186186
the end"""
187187

188188
class TestSFpatches(unittest.TestCase):
189+
189190
def test_html_diff(self):
190191
# Check SF patch 914575 for generating HTML differences
191192
f1a = ((patch914575_from1 + '123\n'*10)*3)

Lib/test/test_difflib_expect.html

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@
99
content="text/html; charset=utf-8" />
1010
<title></title>
1111
<style type="text/css">
12-
table.diff {font-family:Courier; border:medium;}
12+
table.diff {font-family: Menlo, Consolas, Monaco, Liberation Mono, Lucida Console, monospace; border:medium}
1313
.diff_header {background-color:#e0e0e0}
1414
td.diff_header {text-align:right}
1515
.diff_next {background-color:#c0c0c0}

0 commit comments

Comments
 (0)