From f79126f373a9d5c9b584a8db736fe490fcbfa77a Mon Sep 17 00:00:00 2001
From: Brett Cannon <brett@python.org>
Date: Fri, 23 Aug 2013 15:15:48 -0400
Subject: Issue #18394: Explicitly close the file object cgi.FieldStorage
 caches.

Eliminates the ResoureWarning raised during testing.

Patch also independently written by Vajrasky Kok.
---
 Lib/cgi.py | 6 ++++++
 1 file changed, 6 insertions(+)

(limited to 'Lib')

diff --git a/Lib/cgi.py b/Lib/cgi.py
index 4de82ea6df9..b6fd4074546 100755
--- a/Lib/cgi.py
+++ b/Lib/cgi.py
@@ -552,6 +552,12 @@ def __init__(self, fp=None, headers=None, outerboundary=b'',
         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)" % (
-- 
cgit v1.2.3-65-gdbad