Always trap proxy exceptions

This commit is contained in:
Armin Ronacher 2013-01-21 17:44:32 +00:00
parent ff2e8449ff
commit f1537a9d7a
2 changed files with 8 additions and 2 deletions

View file

@ -43,6 +43,8 @@ Release date to be decided.
context which makes them available in imported templates. One has to be context which makes them available in imported templates. One has to be
very careful with those though because usage outside of macros might very careful with those though because usage outside of macros might
cause caching. cause caching.
- Flask will no longer invoke the wrong error handlers if a proxy
exception is passed through.
Version 0.9 Version 0.9
----------- -----------

View file

@ -1327,8 +1327,12 @@ class Flask(_PackageBoundObject):
# ensure not to trash sys.exc_info() at that point in case someone # ensure not to trash sys.exc_info() at that point in case someone
# wants the traceback preserved in handle_http_exception. Of course # wants the traceback preserved in handle_http_exception. Of course
# we cannot prevent users from trashing it themselves in a custom # we cannot prevent users from trashing it themselves in a custom
# trap_http_exception method so that's their fault then. # trap_http_exception method so that's their fault then. Proxy
if isinstance(e, HTTPException) and not self.trap_http_exception(e): # exceptions generally must always be trapped (filtered out by
# e.code == None)
if isinstance(e, HTTPException) \
and e.code is not None \
and not self.trap_http_exception(e):
return self.handle_http_exception(e) return self.handle_http_exception(e)
blueprint_handlers = () blueprint_handlers = ()