diff options
author | Brett Cannon <brett@python.org> | 2013-08-23 15:15:48 -0400 |
---|---|---|
committer | Brett Cannon <brett@python.org> | 2013-08-23 15:15:48 -0400 |
commit | c162cbbc55c26fbbdd8903665a69b022aac7976a (patch) | |
tree | 5d98258854290e782862713209441579fe97090a /Lib | |
parent | f2ddd54639901453cfb1f676b64b40038a903f82 (diff) | |
download | cpython-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-x | Lib/cgi.py | 6 |
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)" % ( |