diff -r 2c27093fd11f Doc/library/cgi.rst --- a/Doc/library/cgi.rst Mon Apr 30 06:20:37 2012 +0200 +++ b/Doc/library/cgi.rst Mon Apr 30 10:37:16 2012 +0200 @@ -87,10 +87,13 @@ have tested your script and are confident that it works correctly. To get at submitted form data, use the :class:`FieldStorage` class. Instantiate -it exactly once, without arguments. This reads the form contents from standard -input or the environment (depending on the value of various environment -variables set according to the CGI standard). Since it may consume standard -input, it should be instantiated only once. +it exactly once. If the form is liable to include non-ASCII characters, provide +the *encoding* keyword parameter, cet to the value of the encoding defined for +the document holding the form (set by a META tag in the HEAD section of the +HTML document, or by the :mailheader:`Content-Type` header). This reads the +form contents from standard input or the environment (depending on the value of +various environment variables set according to the CGI standard). Since it may +consume standard input, it should be instantiated only once. The :class:`FieldStorage` instance can be indexed like a Python dictionary. It allows membership testing with the :keyword:`in` operator, and also supports @@ -136,10 +139,10 @@ If a field represents an uploaded file, accessing the value via the :attr:`value` attribute or the :func:`getvalue` method reads the entire file in -memory as a string. This may not be what you want. You can test for an uploaded +memory as bytes. This may not be what you want. You can test for an uploaded file by testing either the :attr:`filename` attribute or the :attr:`!file` attribute. You can then read the data at leisure from the :attr:`!file` -attribute:: +attribute (the :func:`read` and :func:`readline` methods will return bytes):: fileitem = form["userfile"] if fileitem.file: