Index: Doc/library/difflib.rst =================================================================== --- Doc/library/difflib.rst (revision 86561) +++ Doc/library/difflib.rst (working copy) @@ -723,8 +723,8 @@ # we're passing these as arguments to the diff function fromdate = time.ctime(os.stat(fromfile).st_mtime) todate = time.ctime(os.stat(tofile).st_mtime) - fromlines = open(fromfile, 'U').readlines() - tolines = open(tofile, 'U').readlines() + with open(fromlines) as fromf, open(tofile) as tof: + fromlines, tolines = list(fromf), list(tof) if options.u: diff = difflib.unified_diff(fromlines, tolines, fromfile, tofile,