[issue4953] cgi module cannot handle POST with multipart/form-data in 3.x

Pierre Quentel report at bugs.python.org
Thu Jan 13 16:38:35 CET 2011


Pierre Quentel <pierre.quentel at gmail.com> added the comment:

Ok, thanks. Here is a summary of the API changes :

- the argument fp passed to FieldStorage is either an instance of (a subclass of) io.TextIOBase with a "buffer" attribute for the underlying binary layer (thus, it can't be a StringIO instance) ; or an object with read() and readline() methods that return bytes
Defaults to sys.stdin

- 2 additional arguments can be passed to the FieldStorage constructor :
. stream_encoding : the encoding used by the user agent to encode submitted data. It must be the same as the content-type of the HTML page where the form stands. Defaults to utf-8
. charset : the encoding used by the CGI script (the one used by the print() function to encode and send to sys.stdout). It must be the same as the charset in the content-type header sent by this script. Defaults to None, in which case the default encoding of sys.stdout is used

- the only change in the object returned by FieldStorage() is that, if a field represents a file (its argument filename is not None), the read() method on this field returns bytes, and its attribute "value" is a bytestring, not a string

----------

_______________________________________
Python tracker <report at bugs.python.org>
<http://bugs.python.org/issue4953>
_______________________________________


More information about the Python-bugs-list mailing list