[Web-SIG] WSGI, cgi.FieldStorage incompatibility

Michael Kerrin michael.kerrin at openapp.biz
Fri Sep 29 15:18:26 CEST 2006


Hi All,

  The WSGI specification says in the section on "Input and Error Streams":

      The optional "size" argument to readline() is not supported, as it 
may be
complex for server authors to implement, and is not often used in practice.

  But the current implementation of cgi.FieldStorage in the 2.4.4 branch 
and on Python 2.5 does call readline with the size argument. It has 
started to do this in response to the Python bug #1112549 - 
cgi.FieldStorage memory usage can spike in line-oriented ops. See 
http://sourceforge.net/tracker/index.php?func=detail&aid=1112549&group_id=5470&atid=105470
 
  Since it is reasonable for a WSGI application to use cgi.FieldStorage 
I am wondering whether cgi.FieldStorage or the WSGI specification needs 
to changed in order to solve this incompatibility.

  Originally I thought it was cgi.FieldStorage that needs to be changed, 
and hence tried to fix it by wrapping the input stream so that the 
readline method always uses the read method on the input stream. While 
this seems to work for me it introduces a level of complexity in the 
cgi.py file, and possible some other bugs, that makes me think that 
adding the size argument for readline into the WSGI specification isn't 
such bad idea after all.

  There way be other ways of modifying cgi.FieldStorage to solve this 
but I can't see how at the moment.

  For those that are interested , I have attached the patch but my main 
issue is where should this incompatibility be solved.

  Thanks
  Michael

-------------- next part --------------
A non-text attachment was scrubbed...
Name: cgi.patch
Type: text/x-patch
Size: 5996 bytes
Desc: not available
Url : http://mail.python.org/pipermail/web-sig/attachments/20060929/4d03d5cb/attachment.bin 


More information about the Web-SIG mailing list