summaryrefslogtreecommitdiff
path: root/Lib
diff options
context:
space:
mode:
authorBrett Cannon <brett@python.org>2013-08-23 15:15:48 -0400
committerBrett Cannon <brett@python.org>2013-08-23 15:15:48 -0400
commitc162cbbc55c26fbbdd8903665a69b022aac7976a (patch)
tree5d98258854290e782862713209441579fe97090a /Lib
parentf2ddd54639901453cfb1f676b64b40038a903f82 (diff)
downloadcpython-c162cbbc55c26fbbdd8903665a69b022aac7976a.tar.gz
Issue #18394: Explicitly close the file object cgi.FieldStorage
caches. Eliminates the ResoureWarning raised during testing. Patch also independently written by Vajrasky Kok.
Diffstat (limited to 'Lib')
-rwxr-xr-xLib/cgi.py6
1 files changed, 6 insertions, 0 deletions
diff --git a/Lib/cgi.py b/Lib/cgi.py
index 4de82ea6df..b6fd407454 100755
--- a/Lib/cgi.py
+++ b/Lib/cgi.py
@@ -552,6 +552,12 @@ class FieldStorage:
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)" % (