From f1537a9d7a1e5ab53e38166a2a8fd7bad9278c18 Mon Sep 17 00:00:00 2001 From: Armin Ronacher Date: Mon, 21 Jan 2013 17:44:32 +0000 Subject: [PATCH] Always trap proxy exceptions --- CHANGES | 2 ++ flask/app.py | 8 ++++++-- 2 files changed, 8 insertions(+), 2 deletions(-) diff --git a/CHANGES b/CHANGES index 044dae44..7f3374a1 100644 --- a/CHANGES +++ b/CHANGES @@ -43,6 +43,8 @@ Release date to be decided. context which makes them available in imported templates. One has to be very careful with those though because usage outside of macros might cause caching. +- Flask will no longer invoke the wrong error handlers if a proxy + exception is passed through. Version 0.9 ----------- diff --git a/flask/app.py b/flask/app.py index 162a1d44..5d87b1e8 100644 --- a/flask/app.py +++ b/flask/app.py @@ -1327,8 +1327,12 @@ class Flask(_PackageBoundObject): # ensure not to trash sys.exc_info() at that point in case someone # wants the traceback preserved in handle_http_exception. Of course # we cannot prevent users from trashing it themselves in a custom - # trap_http_exception method so that's their fault then. - if isinstance(e, HTTPException) and not self.trap_http_exception(e): + # trap_http_exception method so that's their fault then. Proxy + # 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) blueprint_handlers = ()