[docs] Bug in the cgi module documentation

Pierre Quentel pierre.quentel at gmail.com
Fri Feb 25 09:28:11 CET 2011


Hi,

I post this message again : the documentation of the cgi module is not in
line with the changes introduced in version 3.2

Best regards,
Pierre

2011/1/23 Pierre Quentel <pierre.quentel at gmail.com>

> Hi,
>
> I wrote a patch for the cgi module in version 3.2rc1. Small changes should
> be done to the documentation of this module to reflect the changes in the
> module API :
>
> - in section "20.2.2. Using the cgi module"
>
> original text :
> "If a field represents an uploaded file, accessing the value via the value
> attribute or the getvalue() method reads the entire file in memory as a
> string. This may not be what you want. You can test for an uploaded file by
> testing either the filename attribute or the file attribute. You can then
> read the data at leisure from the file attribute:"
>
> proposed new text (for files, value is bytes, not string, and the read()
> method on file also returns bytes) :
> "If a field represents an uploaded file, accessing the value via the value
> attribute or the getvalue() 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 filename attribute or the file attribute. You can then read the
> data at leisure from the file attribute (the read() and readline() methods
> will return bytes) :"
>
> - version 3.2 introduced a parameter "encoding" for the FieldStorage
> constructor, used to decode the bytes received on the HTTP connection for
> fields other than files. This encoding must the one defined in the HTML
> document holding the form submitted to the CGI script ; it is usually
> defined by a meta tag :
> <meta http-equiv="Content-type" content="text/html;charset=latin-1">
> or by the Content-Type header for this document
>
> I'm not sure where this should be mentioned in the documentation. Maybe in
> "20.2.9. Common problems and solutions" for the moment. But there are plans
> to introduce another interface to change the encoding of sys.stdout in the
> CGI script itself, so another option would be to open a specific section
> about encodings
>
> Hope it's clear enough
> Pierre
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.python.org/pipermail/docs/attachments/20110225/59d5e97b/attachment.html>


More information about the docs mailing list