<div>Hi,</div>
<div> </div>
<div>In the final version of Python 3.2 the documentation of the cgi module has not been changed, so it&#39;s not in line with what the module does</div>
<div> </div>
<div>It was my first contribution to the documentation so maybe I missed something ?</div>
<div> </div>
<div>Best regards,</div>
<div>Pierre<br><br></div>
<div class="gmail_quote">2011/1/23 Pierre Quentel <span dir="ltr">&lt;<a href="mailto:pierre.quentel@gmail.com">pierre.quentel@gmail.com</a>&gt;</span><br>
<blockquote class="gmail_quote" style="PADDING-LEFT: 1ex; MARGIN: 0px 0px 0px 0.8ex; BORDER-LEFT: #ccc 1px solid">Hi,<br><br>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 :<br>
<br>- in section &quot;20.2.2. Using the cgi module&quot;<br><br>original text :<br>&quot;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:&quot;<br>
<br>proposed new text (for files, value is bytes, not string, and the read() method on file also returns bytes) :<br>&quot;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) :&quot;<br>
<br>- version 2.1 introduced a parameter &quot;encoding&quot; 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 : <br>
&lt;meta http-equiv=&quot;Content-type&quot; content=&quot;text/html;charset=latin-1&quot;&gt;<br>or by the Content-Type header for this document<br><br>I&#39;m not sure where this should be mentioned in the documentation. Maybe in &quot;20.2.9. Common problems and solutions&quot; 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<br>
<br>Hope it&#39;s clear enough<br><font color="#888888">Pierre<br></font></blockquote></div><br>