diff options
author | Mickaƫl Schoentgen <contact@tiger-222.fr> | 2018-09-03 01:48:08 (GMT) |
---|---|---|
committer | Terry Jan Reedy <tjreedy@udel.edu> | 2018-09-03 01:48:08 (GMT) |
commit | 30af2e737aad427d4da97f8dadeeecff6c2b28f5 (patch) | |
tree | d2845d4c83d686f1116d0bb033aa1381a289ed5b /Tools/scripts/diff.py | |
parent | 71f2dadf66c8f9f513bb67f3b06d320c406ac2ff (diff) | |
download | cpython-30af2e737aad427d4da97f8dadeeecff6c2b28f5.zip cpython-30af2e737aad427d4da97f8dadeeecff6c2b28f5.tar.gz cpython-30af2e737aad427d4da97f8dadeeecff6c2b28f5.tar.bz2 |
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.
Diffstat (limited to 'Tools/scripts/diff.py')
-rwxr-xr-x | Tools/scripts/diff.py | 6 |
1 files changed, 4 insertions, 2 deletions
diff --git a/Tools/scripts/diff.py b/Tools/scripts/diff.py index 513e2a7..c4c2e10 100755 --- a/Tools/scripts/diff.py +++ b/Tools/scripts/diff.py @@ -32,8 +32,10 @@ def main(): 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, fromdate, todate, n=n) |