[Web-SIG] An implementation error I just found in PEP 333
Phillip J. Eby
pje at telecommunity.com
Wed Oct 6 01:26:46 CEST 2004
Just a quick heads-up... there's an error in the PEP's CGI implementation,
so if you are basing a server/gateway implementation on it, you may be
copying this error into your own code.
Specifically, 'start_response' contains this code:
elif headers_sent:
raise AssertionError("Headers already sent!")
It *should* read:
elif headers_set:
raise AssertionError("Headers already set!")
This is apparently a typo; it leads to noncompliant behavior (allowing
set_response() to be called multiple times without error even if exc_info
isn't supplied). I discovered it while working on the WSGI reference
library (wsgiref). FYI, the ViewCVS for wsgiref is:
http://cvs.eby-sarna.com/wsgiref/
And you can also get it via anonymous CVS; see
http://peak.telecommunity.com/Meta/AnonymousCVSAccess.html
for instructions, replacing 'co PEAK' with 'co wsgiref'.
At the moment, wsgiref just contains a header manipulation class, a
FileWrapper class, and a bunch of environment manipulation functions, all
with extensive automated tests.
I'm in the middle of working on a base class that can be used to implement
pretty much any kind of WSGI server or gateway, and I noticed that I had
managed to copy the above error into my new base class. So I thought I
should mention it to everybody so they can verify that they didn't make the
same mistake. Sorry about the mixup, I'll get it fixed in the next PEP
revision.
In the meantime, you can now feel good about the fact that even *my* PEP
333 implementation had a compliance bug... ;)
More information about the Web-SIG
mailing list