From 098ea0c8ca3b2f3c6715b1048bec6a42db6298e1 Mon Sep 17 00:00:00 2001 From: Markus Unterwaditzer Date: Sat, 27 Aug 2016 14:32:53 +0200 Subject: [PATCH] Only passthrough_errors if PROPAGATE_EXCEPTIONS See pallets/werkzeug#954 --- flask/app.py | 3 ++- flask/cli.py | 2 +- tests/test_basic.py | 4 ++-- 3 files changed, 5 insertions(+), 4 deletions(-) diff --git a/flask/app.py b/flask/app.py index dac7fe26..ecd94aa8 100644 --- a/flask/app.py +++ b/flask/app.py @@ -838,7 +838,8 @@ class Flask(_PackageBoundObject): self.debug = bool(debug) options.setdefault('use_reloader', self.debug) options.setdefault('use_debugger', self.debug) - options.setdefault('passthrough_errors', True) + options.setdefault('passthrough_errors', + self.config['PROPAGATE_EXCEPTIONS']) try: run_simple(host, port, self, **options) finally: diff --git a/flask/cli.py b/flask/cli.py index 9b8fa2cd..cd301d79 100644 --- a/flask/cli.py +++ b/flask/cli.py @@ -430,7 +430,7 @@ def run_command(info, host, port, reload, debugger, eager_loading, run_simple(host, port, app, use_reloader=reload, use_debugger=debugger, threaded=with_threads, - passthrough_errors=True) + passthrough_errors=app.config['PROPAGATE_EXCEPTIONS']) @click.command('shell', short_help='Runs a shell in the app context.') diff --git a/tests/test_basic.py b/tests/test_basic.py index 55687359..2af7a514 100644 --- a/tests/test_basic.py +++ b/tests/test_basic.py @@ -1268,8 +1268,8 @@ def test_werkzeug_passthrough_errors(monkeypatch, debug, use_debugger, monkeypatch.setattr(werkzeug.serving, 'run_simple', run_simple_mock) app.config['PROPAGATE_EXCEPTIONS'] = propagate_exceptions app.run(debug=debug, use_debugger=use_debugger, use_reloader=use_reloader) - # make sure werkzeug always passes errors through - assert rv['passthrough_errors'] + # make sure werkzeug passes errors through if PROPAGATE_EXCEPTIONS + assert rv['passthrough_errors'] == propagate_exceptions def test_max_content_length():