diff options
-rw-r--r-- | docs/news.txt | 3 | ||||
-rw-r--r-- | paste/httpexceptions.py | 14 | ||||
-rw-r--r-- | paste/wsgilib.py | 2 | ||||
-rw-r--r-- | tests/test_exceptions/test_httpexceptions.py | 27 |
4 files changed, 7 insertions, 39 deletions
diff --git a/docs/news.txt b/docs/news.txt index 33474f0..f13ce88 100644 --- a/docs/news.txt +++ b/docs/news.txt @@ -16,6 +16,9 @@ svn trunk * In ``paste.session``, when cleaning files ignore files that aren't session files. +* ``paste.httpexceptions.HTTPExceptionHandler`` will no longer catch + exceptions raised during the app_iter iteration. + 1.4.2 ----- diff --git a/paste/httpexceptions.py b/paste/httpexceptions.py index 946f8f3..cd3b81a 100644 --- a/paste/httpexceptions.py +++ b/paste/httpexceptions.py @@ -628,18 +628,10 @@ class HTTPExceptionHandler(object): environ['paste.httpexceptions'] = self environ.setdefault('paste.expected_exceptions', []).append(HTTPException) - return catch_errors_app( - self.application, environ, start_response, - self.send_http_response, catch=HTTPException) - - def send_http_response(self, environ, start_response, exc_info): try: - exc = exc_info[1] - assert(isinstance(exc, HTTPException)), \ - 'send_http_response triggered via a non HTTPException' - return exc.wsgi_application(environ, start_response, exc_info) - finally: - exc_info = None + return self.application(environ, start_response) + except HTTPException, exc: + return exc(environ, start_response) def middleware(*args, **kw): import warnings diff --git a/paste/wsgilib.py b/paste/wsgilib.py index 9960587..02dd2dc 100644 --- a/paste/wsgilib.py +++ b/paste/wsgilib.py @@ -227,7 +227,7 @@ def catch_errors_app(application, environ, start_response, error_callback_app, return error_callback_app(environ, start_response, sys.exc_info()) if type(app_iter) in (list, tuple): # These won't produce exceptions - if ok_callback: + if ok_callback is not None: ok_callback() return app_iter else: diff --git a/tests/test_exceptions/test_httpexceptions.py b/tests/test_exceptions/test_httpexceptions.py index de1afd3..4ca64a4 100644 --- a/tests/test_exceptions/test_httpexceptions.py +++ b/tests/test_exceptions/test_httpexceptions.py @@ -58,33 +58,6 @@ def test_template(): assert '<p>A fun and <b>happy</b> message.</p>' in \ e.html({'ping': 'fun', 'pong': 'happy'}) -def test_iterator_application(): - """ - This tests to see that an iterator's exceptions are caught by - HTTPExceptionHandler - """ - def basic_found(environ, start_response): - raise HTTPFound("/bing/foo") - return ['result'] - app = HTTPExceptionHandler(basic_found) - (status, headers, content, errors) = raw_interactive(app) - assert '302 Found' == status - def make_iter(application): - def iterapp(environ, start_response): - result = application(environ, start_response) - for chunk in result: - yield chunk - return iterapp - app = HTTPExceptionHandler(make_iter(basic_found)) - (status, headers, content, errors) = raw_interactive(app) - assert '302 Found' == status - def iterate_found(environ, start_response): - raise HTTPFound("/bing/foo") - yield 'result' - app = HTTPExceptionHandler(iterate_found) - (status, headers, content, errors) = raw_interactive(app) - assert '302 Found' == status - def test_redapp(): """ check that redirect returns the correct, expected results """ saved = [] |