bpo-34500: Fix ResourceWarning in difflib.py (GH-8926)

The change to Tools/scripts/diff.py effectively backports part of
a2637729f23dc993e820fd92f0d1759ad714c9b2.
The test code changed in Doc/library/difflib.rst is not present in current 3.x.
diff --git a/Doc/library/difflib.rst b/Doc/library/difflib.rst
index c6bf3ef..01a3bfc 100644
--- a/Doc/library/difflib.rst
+++ b/Doc/library/difflib.rst
@@ -757,8 +757,10 @@
        # 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(fromfile, 'U') as f:
+           fromlines = f.readlines()
+       with open(tofile, 'U') as f:
+           tolines = f.readlines()
 
        if options.u:
            diff = difflib.unified_diff(fromlines, tolines, fromfile, tofile,