Commits

Brett Cannon  committed c0e9ba7

Issue #18394: Explicitly close the file object cgi.FieldStorage
caches.

Eliminates the ResoureWarning raised during testing.

Patch also independently written by Vajrasky Kok.

  • Participants
  • Parent commits 2ca51a6

Comments (0)

Files changed (2)

         else:
             self.read_single()
 
+    def __del__(self):
+        try:
+            self.file.close()
+        except AttributeError:
+            pass
+
     def __repr__(self):
         """Return a printable representation."""
         return "FieldStorage(%r, %r, %r)" % (
 Library
 -------
 
+- Issue #18394: Close cgi.FieldStorage's optional file.
+
 - Issue #17702: On error, os.environb now removes suppress the except context
   when raising a new KeyError with the original key.