From f9813e050988e69b3b972bcc4495671bde2dafa7 Mon Sep 17 00:00:00 2001 From: Michael Merickel Date: Thu, 6 Jun 2019 22:06:40 -0500 Subject: do not reinvoke exception views if an exception hits the execution policy See https://github.com/Pylons/pyramid/issues/3468 --- src/pyramid/router.py | 5 +---- tests/test_router.py | 5 ++--- 2 files changed, 3 insertions(+), 7 deletions(-) diff --git a/src/pyramid/router.py b/src/pyramid/router.py index 19641aecd..fa1a9ebf7 100644 --- a/src/pyramid/router.py +++ b/src/pyramid/router.py @@ -273,7 +273,4 @@ class Router(object): def default_execution_policy(environ, router): with router.request_context(environ) as request: - try: - return router.invoke_request(request) - except Exception: - return request.invoke_exception_view(reraise=True) + return router.invoke_request(request) diff --git a/tests/test_router.py b/tests/test_router.py index 3e66757f6..722f4286c 100644 --- a/tests/test_router.py +++ b/tests/test_router.py @@ -1561,7 +1561,7 @@ class TestRouter(unittest.TestCase): self.assertEqual(resp.status_code, 200) self.assertEqual(resp.body, b'foo') - def test_execution_policy_handles_exception(self): + def test_execution_policy_bubbles_exception(self): from pyramid.interfaces import IViewClassifier from pyramid.interfaces import IExceptionViewClassifier from pyramid.interfaces import IRequest @@ -1591,8 +1591,7 @@ class TestRouter(unittest.TestCase): environ = self._makeEnviron(PATH_INFO='/archives/action1/article1') start_response = DummyStartResponse() router = self._makeOne() - result = router(environ, start_response) - self.assertEqual(result, ["Hello, world"]) + self.assertRaises(Exception2, lambda: router(environ, start_response)) def test_request_context_with_statement(self): from pyramid.threadlocal import get_current_request -- cgit v1.2.3