diff options
| author | Chris McDonough <chrism@plope.com> | 2011-08-10 19:08:49 -0400 |
|---|---|---|
| committer | Chris McDonough <chrism@plope.com> | 2011-08-10 19:08:49 -0400 |
| commit | 3e3fcdf1376218a4fa6dcffec4f27a41c63d1675 (patch) | |
| tree | 066375fa85addf32c786b838d81dc996f6da87d6 | |
| parent | 01d793025197e9d3b7749f475050f55a17dfd145 (diff) | |
| download | pyramid-3e3fcdf1376218a4fa6dcffec4f27a41c63d1675.tar.gz pyramid-3e3fcdf1376218a4fa6dcffec4f27a41c63d1675.tar.bz2 pyramid-3e3fcdf1376218a4fa6dcffec4f27a41c63d1675.zip | |
clean off exception attr from request too
| -rw-r--r-- | pyramid/tests/test_router.py | 11 | ||||
| -rw-r--r-- | pyramid/tweens.py | 7 |
2 files changed, 10 insertions, 8 deletions
diff --git a/pyramid/tests/test_router.py b/pyramid/tests/test_router.py index 19134813f..2b00cba22 100644 --- a/pyramid/tests/test_router.py +++ b/pyramid/tests/test_router.py @@ -812,10 +812,8 @@ class TestRouter(unittest.TestCase): start_response = DummyStartResponse() result = router(environ, start_response) self.assertEqual(result, ['OK']) - # ``exception`` must be attached to request even if a suitable - # exception view cannot be found - self.assertEqual(request.exception.__class__, RuntimeError) - # we clean up the exc_info after the request + # we clean up the exc_info and exception after the request + self.assertEqual(request.exception, None) self.assertEqual(request.exc_info, None) def test_call_view_raises_exception_view(self): @@ -826,7 +824,9 @@ class TestRouter(unittest.TestCase): exception_response = DummyResponse() exception_response.app_iter = ["Hello, world"] view = DummyView(response, raise_exception=RuntimeError) - exception_view = DummyView(exception_response) + def exception_view(context, request): + self.assertEqual(request.exception.__class__, RuntimeError) + return exception_response environ = self._makeEnviron() self._registerView(view, '', IViewClassifier, IRequest, None) self._registerView(exception_view, '', IExceptionViewClassifier, @@ -835,7 +835,6 @@ class TestRouter(unittest.TestCase): start_response = DummyStartResponse() result = router(environ, start_response) self.assertEqual(result, ["Hello, world"]) - self.assertEqual(view.request.exception.__class__, RuntimeError) def test_call_view_raises_super_exception_sub_exception_view(self): from pyramid.interfaces import IViewClassifier diff --git a/pyramid/tweens.py b/pyramid/tweens.py index 54da9b15a..5ada88b24 100644 --- a/pyramid/tweens.py +++ b/pyramid/tweens.py @@ -36,8 +36,11 @@ def excview_tween_factory(handler, registry): raise response = view_callable(exc, request) finally: - # prevent leakage - attrs['exc_info'] = None + # prevent leakage (wrt exc_info) + if 'exc_info' in attrs: + del attrs['exc_info'] + if 'exception' in attrs: + del attrs['exception'] return response |
