diff options
author | Brett Cannon <brett@python.org> | 2014-01-17 16:03:19 (GMT) |
---|---|---|
committer | Brett Cannon <brett@python.org> | 2014-01-17 16:03:19 (GMT) |
commit | c089f70b54f30398f870216925e75bff398d0254 (patch) | |
tree | 504d143699f18cf65cdce88425882df4ab736f9d /Doc/library/cgi.rst | |
parent | 50c8583492dfe475a44ffc3cd4ed96903a844144 (diff) | |
download | cpython-c089f70b54f30398f870216925e75bff398d0254.zip cpython-c089f70b54f30398f870216925e75bff398d0254.tar.gz cpython-c089f70b54f30398f870216925e75bff398d0254.tar.bz2 |
Issue #18394: Document that cgi.FieldStorage now cleans up after its
'file' attribute properly in Python 3.4.
Thanks to Marcel Hellkamp for pointing out the oversight.
Diffstat (limited to 'Doc/library/cgi.rst')
-rw-r--r-- | Doc/library/cgi.rst | 13 |
1 files changed, 10 insertions, 3 deletions
diff --git a/Doc/library/cgi.rst b/Doc/library/cgi.rst index c4e7c60..fa13145 100644 --- a/Doc/library/cgi.rst +++ b/Doc/library/cgi.rst @@ -142,9 +142,11 @@ If a field represents an uploaded file, accessing the value via the method reads the entire file in memory as bytes. This may not be what you want. You can test for an uploaded file by testing either the :attr:`~FieldStorage.filename` attribute or the :attr:`~FieldStorage.file` -attribute. You can then read the data at leisure from the :attr:`!file` -attribute (the :func:`~io.RawIOBase.read` and :func:`~io.IOBase.readline` -methods will return bytes):: +attribute. You can then read the data from the :attr:`!file` +attribute before it is automatically closed as part of the garbage collection of +the :class:`FieldStorage` instance +(the :func:`~io.RawIOBase.read` and :func:`~io.IOBase.readline` methods will +return bytes):: fileitem = form["userfile"] if fileitem.file: @@ -176,6 +178,11 @@ actually be instances of the class :class:`MiniFieldStorage`. In this case, the A form submitted via POST that also has a query string will contain both :class:`FieldStorage` and :class:`MiniFieldStorage` items. +.. versionchanged:: 3.4 + The :attr:`~FieldStorage.file` attribute is automatically closed upon the + garbage collection of the creating :class:`FieldStorage` instance. + + Higher Level Interface ---------------------- |