mirror of
https://github.com/python/cpython.git
synced 2025-08-30 05:35:08 +00:00
Issue #20289: cgi.FieldStorage() now supports the context management protocol.
This commit is contained in:
parent
088ca8b947
commit
bf5e9604cc
5 changed files with 35 additions and 6 deletions
|
@ -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)" % (
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue