diff options
| author | Berker Peksag <berker.peksag@gmail.com> | 2015-02-06 10:21:37 +0200 |
|---|---|---|
| committer | Berker Peksag <berker.peksag@gmail.com> | 2015-02-06 10:21:37 +0200 |
| commit | bf5e9604cc5a5ae61181b093193286f06a502ad6 (patch) | |
| tree | c20966ea695e430b9dddae88196def7aca84f309 /Lib/cgi.py | |
| parent | 088ca8b9470e51b932b73d6b39d970b0292f2ba3 (diff) | |
| download | cpython-git-bf5e9604cc5a5ae61181b093193286f06a502ad6.tar.gz | |
Issue #20289: cgi.FieldStorage() now supports the context management protocol.
Diffstat (limited to 'Lib/cgi.py')
| -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 1ef780c11c..a55232eb62 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)" % ( |
