Skip to content

Commit 81ae94a

Browse files
committed
Merge branch '0.10-maintenance'
2 parents 97c0b26 + 6a6a6d8 commit 81ae94a

3 files changed

Lines changed: 17 additions & 2 deletions

File tree

CHANGES

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -91,6 +91,8 @@ Version 0.10.2
9191
- Changed logic of before first request handlers to flip the flag after
9292
invoking. This will allow some uses that are potentially dangerous but
9393
should probably be permitted.
94+
- Fixed Python 3 bug when a handler from `app.url_build_error_handlers`
95+
reraises the `BuildError`.
9496

9597
Version 0.10.1
9698
--------------

flask/app.py

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1769,8 +1769,9 @@ def handle_url_build_error(self, error, endpoint, values):
17691769
rv = handler(error, endpoint, values)
17701770
if rv is not None:
17711771
return rv
1772-
except BuildError as error:
1773-
pass
1772+
except BuildError as e:
1773+
# make error available outside except block (py3)
1774+
error = e
17741775

17751776
# At this point we want to reraise the exception. If the error is
17761777
# still the same one we can reraise it with the original traceback,

tests/test_basic.py

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1069,6 +1069,18 @@ def handler(error, endpoint, values):
10691069
assert flask.url_for('spam') == '/test_handler/'
10701070

10711071

1072+
def test_build_error_handler_reraise():
1073+
app = flask.Flask(__name__)
1074+
1075+
# Test a custom handler which reraises the BuildError
1076+
def handler_raises_build_error(error, endpoint, values):
1077+
raise error
1078+
app.url_build_error_handlers.append(handler_raises_build_error)
1079+
1080+
with app.test_request_context():
1081+
pytest.raises(BuildError, flask.url_for, 'not.existing')
1082+
1083+
10721084
def test_custom_converters():
10731085
from werkzeug.routing import BaseConverter
10741086

0 commit comments

Comments
 (0)