Skip to content

Commit c28a168

Browse files
committed
Merge branch 'Diggsey-db-handle-baseexceptions' into 0.12-maintenance
2 parents b0820bc + 6f7847e commit c28a168

File tree

3 files changed

+35
-0
lines changed

3 files changed

+35
-0
lines changed

CHANGES

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,21 @@ Flask Changelog
33

44
Here you can see the full list of changes between each Flask release.
55

6+
Version 0.13
7+
------------
8+
9+
Major release, unreleased
10+
11+
- Make `app.run()` into a noop if a Flask application is run from the
12+
development server on the command line. This avoids some behavior that
13+
was confusing to debug for newcomers.
14+
- Change default configuration `JSONIFY_PRETTYPRINT_REGULAR=False`. jsonify()
15+
method returns compressed response by default, and pretty response in
16+
debug mode.
17+
- Call `ctx.auto_pop` with the exception object instead of `None`, in the
18+
event that a `BaseException` such as `KeyboardInterrupt` is raised in a
19+
request handler.
20+
621
Version 0.12.1
722
--------------
823

flask/app.py

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1983,6 +1983,9 @@ def wsgi_app(self, environ, start_response):
19831983
except Exception as e:
19841984
error = e
19851985
response = self.handle_exception(e)
1986+
except:
1987+
error = sys.exc_info()[1]
1988+
raise
19861989
return response(environ, start_response)
19871990
finally:
19881991
if self.should_ignore_error(error):

tests/test_basic.py

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -791,6 +791,23 @@ def after_request(resp):
791791
assert resp.data == b'internal server error'
792792

793793

794+
def test_baseexception_error_handling():
795+
app = flask.Flask(__name__)
796+
app.config['LOGGER_HANDLER_POLICY'] = 'never'
797+
798+
@app.route('/')
799+
def broken_func():
800+
raise KeyboardInterrupt()
801+
802+
with app.test_client() as c:
803+
with pytest.raises(KeyboardInterrupt):
804+
c.get('/')
805+
806+
ctx = flask._request_ctx_stack.top
807+
assert ctx.preserved
808+
assert type(ctx._preserved_exc) is KeyboardInterrupt
809+
810+
794811
def test_before_request_and_routing_errors():
795812
app = flask.Flask(__name__)
796813

0 commit comments

Comments
 (0)