Closed GoogleCodeExporter closed 8 years ago
In general, error handling that tries to account for every weird way people can
get something wrong can just get too complicated. All the same, I'll leave the
issue here and look at it at some point and see if any improvements can be
made. One thing that may be done is that Python does have the ability to add
validators for 'O' arguments so you can say that is expected that they be
certain types.
Original comment by Graham.Dumpleton@gmail.com
on 8 Jan 2011 at 12:07
Agree that in the end the fault was entirely our own; we were just mislead by
the type and wording of the exception "SystemError: new style getargs format
[...]". Because it's talking about "new style getargs" this hinted at some
C-level fault and led us astray in the debugging :-)
I did think it might have been our start_response(...) call, but was confused
why we'd get this error (expecting that it was coming from the _first_ parse of
the arguments, not a later second-parse of the final argument.)
If it can be checked that the final O is really a tuple, it might save someone
else in the future a lot of time.
Thanks for considering it!
Original comment by nick.pi...@logica.com
on 8 Jan 2011 at 11:54
Looking at code now, yes it was an omission that basic type check for tuple
wasn't being done.
This is fixed now in revision 1754 of trunk for mod_wsgi 4.0.
The code now does:
if (!PyArg_ParseTuple(args, "OO!|O!:start_response",
&item, &PyList_Type, &headers, &PyTuple_Type, &exc_info)) {
return NULL;
}
That is, check that type of argument is tuple when first passed in to
start_response().
The error you will get now is:
File "/Library/WebServer/Sites/hello-1/htdocs/hello-py3k.wsgi", line 7, in
application
start_response(status, response_headers, [])
TypeError: must be tuple, not list
As usual, Python isn't going to tell which argument of function, but is better
than before.
Original comment by Graham.Dumpleton@gmail.com
on 18 Jan 2011 at 6:39
This is having a side effect on, at least, Python 2.7.1 on Mac OS 10.7.1
(Python as supplied by Apple) when using, amongst other, the Pylons framework.
What is happening there is that sometimes "None" is passed as exc_info, which
no longer is allowed with this change to parsing. So it might be better to
switch back to using the plain "O" format instead of "O!", and then verify that
either no argument was passed, None was passed or a tuple, and only raise an
exception if it is none of those...
Original comment by tlock...@gmail.com
on 10 Sep 2011 at 9:08
Yes, am aware of this. I rambled about the issue at:
https://plus.google.com/114657481176404420131/posts/NxMETz1mAUj
As usual, not too much of a response and so had just left it to see when
someone would actually notice it was a problem so could see which frameworks
were not necessarily following the letter of the specification. :-)
I have reopened the issue.
Original comment by Graham.Dumpleton@gmail.com
on 10 Sep 2011 at 9:18
The mod_wsgi 4.X repository trunk is now accepting None again for exc_info when
calling start_response().
Original comment by Graham.Dumpleton@gmail.com
on 24 Sep 2011 at 5:49
Original comment by Graham.Dumpleton@gmail.com
on 19 Mar 2012 at 10:24
Closing out old issue. Believe all is okay in 4.X.
Original comment by Graham.Dumpleton@gmail.com
on 12 Nov 2014 at 10:49
Original issue reported on code.google.com by
nick.pi...@logica.com
on 7 Jan 2011 at 8:45