[New-bugs-announce] [issue11066] cgi.py proposals : sys.stdout encoding + rewriting of parsing functions

Pierre Quentel report at bugs.python.org
Sat Jan 29 22:15:41 CET 2011

New submission from Pierre Quentel <pierre.quentel at gmail.com>:

Python 3.2rc1 introduced a new version of cgi.py that handles correctly file uploads

In this version, the FieldStorage constructor receives an argument "encoding" which is the encoding used by the document holding the submitted form

On the CGI script side, there is currently no easy way to print the received form fields with another encoding than sys.stdout.encoding. 

The proposed version introduces a function, set_stdout_encoding(charset), which can be used in the CGI script to set sys.stdout to an instance of a class that uses the charset encoding. This way, print() will use this encoding. "charset" must be the encoding defined in the content-type header sent by the CGI scrpt

This class (IOMix) was written by Glen Linderman and proposed in the 3.2rc1 version, but no consensus could be reached on time for the release

Another proposed change is a rewriting of the module-level functions parse() and parse_multipart() : they now use the FieldStorage methods instead

components: Library (Lib)
files: cgi_20110129.diff
keywords: patch
messages: 127487
nosy: quentel
priority: normal
severity: normal
status: open
title: cgi.py proposals : sys.stdout encoding + rewriting of parsing functions
type: behavior
versions: Python 3.3
Added file: http://bugs.python.org/file20612/cgi_20110129.diff

Python tracker <report at bugs.python.org>

More information about the New-bugs-announce mailing list