Skip to content

Commit

Permalink
do not reinvoke exception views if an exception hits the execution po…
Browse files Browse the repository at this point in the history
…licy

See Pylons#3468
  • Loading branch information
mmerickel committed Jun 7, 2019
1 parent 0a3f842 commit f9813e0
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 7 deletions.
5 changes: 1 addition & 4 deletions src/pyramid/router.py
Original file line number Diff line number Diff line change
Expand Up @@ -273,7 +273,4 @@ def __call__(self, environ, start_response):

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)
5 changes: 2 additions & 3 deletions tests/test_router.py
Original file line number Diff line number Diff line change
Expand Up @@ -1561,7 +1561,7 @@ def dummy_policy(environ, router):
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
Expand Down Expand Up @@ -1591,8 +1591,7 @@ class Exception2(Exception):
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
Expand Down

0 comments on commit f9813e0

Please # to comment.