mirror of
https://github.com/python/cpython.git
synced 2025-08-04 08:59:19 +00:00
Issue #18394: Explicitly close the file object cgi.FieldStorage
caches. Eliminates the ResoureWarning raised during testing. Patch also independently written by Vajrasky Kok.
This commit is contained in:
parent
9c7eb55570
commit
f79126f373
2 changed files with 8 additions and 0 deletions
|
@ -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)" % (
|
||||
|
|
|
@ -38,6 +38,8 @@ Core and Builtins
|
|||
Library
|
||||
-------
|
||||
|
||||
- Issue #18394: Close cgi.FieldStorage's optional file.
|
||||
|
||||
- Issue #17702: On error, os.environb now removes suppress the except context
|
||||
when raising a new KeyError with the original key.
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue