Issue #20289: cgi.FieldStorage() now supports the context management protocol.

This commit is contained in:
Berker Peksag 2015-02-06 10:21:37 +02:00
parent 088ca8b947
commit bf5e9604cc
5 changed files with 35 additions and 6 deletions

View file

@ -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)" % (