summaryrefslogtreecommitdiffstats
path: root/Lib/cgi.py
diff options
context:
space:
mode:
authorBerker Peksag <berker.peksag@gmail.com>2015-02-06 08:21:37 (GMT)
committerBerker Peksag <berker.peksag@gmail.com>2015-02-06 08:21:37 (GMT)
commitbf5e9604cc5a5ae61181b093193286f06a502ad6 (patch)
treec20966ea695e430b9dddae88196def7aca84f309 /Lib/cgi.py
parent088ca8b9470e51b932b73d6b39d970b0292f2ba3 (diff)
downloadcpython-bf5e9604cc5a5ae61181b093193286f06a502ad6.zip
cpython-bf5e9604cc5a5ae61181b093193286f06a502ad6.tar.gz
cpython-bf5e9604cc5a5ae61181b093193286f06a502ad6.tar.bz2
Issue #20289: cgi.FieldStorage() now supports the context management protocol.
Diffstat (limited to 'Lib/cgi.py')
-rwxr-xr-xLib/cgi.py6
1 files changed, 6 insertions, 0 deletions
diff --git a/Lib/cgi.py b/Lib/cgi.py
index 1ef780c..a55232e 100755
--- a/Lib/cgi.py
+++ b/Lib/cgi.py
@@ -566,6 +566,12 @@ class FieldStorage:
except AttributeError:
pass
+ def __enter__(self):
+ return self
+
+ def __exit__(self, *args):
+ self.file.close()
+
def __repr__(self):
"""Return a printable representation."""
return "FieldStorage(%r, %r, %r)" % (