aboutsummaryrefslogtreecommitdiff
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
commitf79126f373a9d5c9b584a8db736fe490fcbfa77a (patch)
tree18a06f40da038953f80ccb86658f8d361924b1b2 /Lib
parentStop using assertEquals. (diff)
downloadcpython-f79126f373a9d5c9b584a8db736fe490fcbfa77a.tar.gz
cpython-f79126f373a9d5c9b584a8db736fe490fcbfa77a.tar.bz2
cpython-f79126f373a9d5c9b584a8db736fe490fcbfa77a.zip
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 4de82ea6df9..b6fd4074546 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)" % (