Fix #12811 by closing files promptly in tabnanny.check. Patch by Anthony Briggs.
diff --git a/Lib/tabnanny.py b/Lib/tabnanny.py
index 46f8163..4a54f89 100755
--- a/Lib/tabnanny.py
+++ b/Lib/tabnanny.py
@@ -126,6 +126,9 @@
             else: print(file, badline, repr(line))
         return
 
+    finally:
+        f.close()
+
     if verbose:
         print("%r: Clean bill of health." % (file,))