pecan.abort exception changes on each run

Bug #1478732 reported by Stanislaw Pitucha
8
This bug affects 1 person
Affects Status Importance Assigned to Milestone
pecan
Invalid
Undecided
Unassigned

Bug Description

There's an issue with the way Pecan chooses exception to raise on pecan.abort(). The exception is selected based only on the http status code, but that's not a 1-many mapping.

When webob initialises the status_map, any out of 5 exceptions can end up being the last one assigned to 500 for example. With some debugging code:

added error 500 = <class 'webob.exc.HTTPInternalServerError'>
added error 500 = <class 'webob.exc.HTTPError'>
added error 500 = <class 'webob.exc.HTTPServerError'>
added error 500 = <class 'webob.exc.WSGIHTTPException'>
added error 500 = <class 'webob.exc.HTTPRedirection'>

This wouldn't be that bad if they were all HTTPServerError-s for example. But here WSGIHTTPException comes from a different hierarhy and it's not a child of HTTPServerError, only of HTTPError.

While this doesn't make much difference at runtime and the final response for the user, it affects functional testing of pecan apps. Anchor ran into this issue when testing for failures produced by pecan.abort(500, "..."). On half of the test runs the expected HTTPServerError was caught, on the other half WSGIHTTPException broke the testing.

I think pecan should keep its own status map keeping the most specific errors only (like the table in the comment at https://github.com/Pylons/webob/blob/master/webob/exc.py#L20). But I'm sure there are other possible solutions. The most important thing is that pecan should return the same error on every run, not a random one.

Revision history for this message
Ryan Petrello (ryan-petrello) wrote :
Changed in pecan:
status: New → Invalid
To post a comment you must log in.
This report contains Public information  
Everyone can see this information.

Other bug subscribers

Remote bug watches

Bug watches keep track of this bug in other bug trackers.