Skip to content

Commit a106f61

Browse files
[3.11] gh-54434: Make difflib.rst doctests pass. (GH-111677) (#111679)
gh-54434: Make difflib.rst doctests pass. (GH-111677) (cherry picked from commit 0d3df27) Co-authored-by: Terry Jan Reedy <tjreedy@udel.edu>
1 parent e61f2ed commit a106f61

File tree

1 file changed

+5
-3
lines changed

1 file changed

+5
-3
lines changed

Doc/library/difflib.rst

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -173,9 +173,12 @@ diffs. For comparing directories and files, see also, the :mod:`filecmp` module.
173173
expressed in the ISO 8601 format. If not specified, the
174174
strings default to blanks.
175175

176+
>>> import sys
177+
>>> from difflib import *
176178
>>> s1 = ['bacon\n', 'eggs\n', 'ham\n', 'guido\n']
177179
>>> s2 = ['python\n', 'eggy\n', 'hamster\n', 'guido\n']
178-
>>> sys.stdout.writelines(context_diff(s1, s2, fromfile='before.py', tofile='after.py'))
180+
>>> sys.stdout.writelines(context_diff(s1, s2, fromfile='before.py',
181+
... tofile='after.py'))
179182
*** before.py
180183
--- after.py
181184
***************
@@ -298,13 +301,12 @@ diffs. For comparing directories and files, see also, the :mod:`filecmp` module.
298301
For inputs that do not have trailing newlines, set the *lineterm* argument to
299302
``""`` so that the output will be uniformly newline free.
300303

301-
The context diff format normally has a header for filenames and modification
304+
The unified diff format normally has a header for filenames and modification
302305
times. Any or all of these may be specified using strings for *fromfile*,
303306
*tofile*, *fromfiledate*, and *tofiledate*. The modification times are normally
304307
expressed in the ISO 8601 format. If not specified, the
305308
strings default to blanks.
306309

307-
308310
>>> s1 = ['bacon\n', 'eggs\n', 'ham\n', 'guido\n']
309311
>>> s2 = ['python\n', 'eggy\n', 'hamster\n', 'guido\n']
310312
>>> sys.stdout.writelines(unified_diff(s1, s2, fromfile='before.py', tofile='after.py'))

0 commit comments

Comments
 (0)