diff options
| author | Michael Merickel <michael@merickel.org> | 2016-05-10 01:53:19 -0500 |
|---|---|---|
| committer | Michael Merickel <michael@merickel.org> | 2016-05-10 01:53:19 -0500 |
| commit | e5561fcabb09173bdc12fbd47bf83aaa0407f09d (patch) | |
| tree | 1c3a01751b41a7a62acbc5549fe48074a019ea15 | |
| parent | 1b3554b541618da9021cac26a49ea6976e66a655 (diff) | |
| download | pyramid-e5561fcabb09173bdc12fbd47bf83aaa0407f09d.tar.gz pyramid-e5561fcabb09173bdc12fbd47bf83aaa0407f09d.tar.bz2 pyramid-e5561fcabb09173bdc12fbd47bf83aaa0407f09d.zip | |
fix excview tween to reraise the original exception if left unhandled by exception views
fixes #2566
| -rw-r--r-- | pyramid/tweens.py | 31 |
1 files changed, 21 insertions, 10 deletions
diff --git a/pyramid/tweens.py b/pyramid/tweens.py index d6044dcdc..a842b1133 100644 --- a/pyramid/tweens.py +++ b/pyramid/tweens.py @@ -1,5 +1,7 @@ import sys +from pyramid.compat import reraise +from pyramid.exceptions import PredicateMismatch from pyramid.interfaces import ( IExceptionViewClassifier, IRequest, @@ -38,17 +40,26 @@ def excview_tween_factory(handler, registry): # https://github.com/Pylons/pyramid/issues/700 request_iface = attrs.get('request_iface', IRequest) provides = providedBy(exc) - response = _call_view( - registry, - request, - exc, - provides, - '', - view_classifier=IExceptionViewClassifier, - request_iface=request_iface.combined - ) + try: + response = _call_view( + registry, + request, + exc, + provides, + '', + view_classifier=IExceptionViewClassifier, + request_iface=request_iface.combined + ) + + # if views matched but did not pass predicates, squash the error + # and re-raise the original exception + except PredicateMismatch: + response = None + + # re-raise the original exception as no exception views were + # able to handle the error if response is None: - raise + reraise(*attrs['exc_info']) return response |
