Glenn Linderman <v+pyt...@g.nevcal.com> added the comment:

Victor said:
"Set sys.stdin.buffer.encoding attribute is not a good idea. Why do you modify 
fp, instead of using a separated attribute on FieldStorage (eg. 
self.fp_encoding)?"

Pierre said:
I set an attribute encoding to self.fp because, for each part of a 
multipart/form-data, a new instance of FieldStorage is created, and this 
instance needs to know how to decode bytes. So, either an attribute must be set 
to one of the arguments of the FieldStorage constructor, and fp comes to mind, 
or an extra argument has to be passed to this constructor, i.e. the encoding of 
the original stream

I say:
Ah, now I understand why you did it that way, but:

The RFC 2616 says the CGI stream is ISO-8859-1 (or latin-1).  The _defined_ 
encoding of the original stream is irrelevant, in the same manner that if it is 
a text stream, that is irrelevant.  The stream is binary, and latin-1, or it is 
non-standard.  Hence, there is not any reason to need a parameter, just use 
latin-1. If non-standard streams are to be supported, I suppose that would 
require a parameter, but I see no need to support non-standard streams: it is 
hard enough to support standard streams without complicating things.  The 
encoding provided with stdin is reasonably unlikely to be latin-1: Linux 
defaults to UTF-8 (at least on many distributions), and Windows to CP437, and 
in either case is configurable by the sysadmin.  But even the sysadmin should 
not be expected to configure the system locale to have latin-1 as the default 
encoding for the system, just because one of the applications that might run is 
an CGI program.  So I posit that the encoding on fp is irrelevan
 t and should be ignored, and using it as a parameter between FieldStorage 
instances is neither appropriate nor necessary, as the standard defines latin-1 
as the encoding for the stream.

----------

_______________________________________
Python tracker <rep...@bugs.python.org>
<http://bugs.python.org/issue4953>
_______________________________________
_______________________________________________
Python-bugs-list mailing list
Unsubscribe: 
http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com

Reply via email to