Skip to content
Myr

Merge branch 'lobeck-fix_unboundlocalerror_for_handle_build_error' into 0.10-maintenance

Before adoption: this commit came in with the history the project adopted, so no landing records it.

Fix #1533

authored by Markus Unterwaditzer · committed by Markus Unterwaditzer · parents d734baf, 765f851 · Browse files · 3 files+16 added−2 removed
This commit

State

Before adoption: this commit came in with the history the project adopted, so no landing records it.

Diff stats

3 files+16 added−2 removed

  • other:+16 added−2 removed

3 files+16 added−2 removed

modified:flask/testsuite/basic.py+11 added
770 unmodified lines
771 app.url_build_error_handlers.append(handler)772 with app.test_request_context():773 self.assert_equal(flask.url_for('spam'), '/test_handler/')774775 def test_build_error_handler_reraise(self):776 app = flask.Flask(__name__)777778 # Test a custom handler which reraises the BuildError779 def handler_raises_build_error(error, endpoint, values):780 raise error781 app.url_build_error_handlers.append(handler_raises_build_error)782783 with app.test_request_context():784 self.assertRaises(BuildError, flask.url_for, 'not.existing')785786 def test_custom_converters(self):787 from werkzeug.routing import BaseConverter788 class ListConverter(BaseConverter):789 def to_python(self, value):
497 unmodified lines
modified:flask/app.py+3 added-2 removed
1629 unmodified lines
1630 try:1631 rv = handler(error, endpoint, values)1632 if rv is not None:1633 return rv1634 except BuildError as error:1635 pass1634 except BuildError as e:1635 # make error available outside except block (py3)1636 error = e16371638 # At this point we want to reraise the exception. If the error is1639 # still the same one we can reraise it with the original traceback,1640 # otherwise we raise it from here.
203 unmodified lines
modified:CHANGES+2 added
21 unmodified lines
22 correctly.23- Changed logic of before first request handlers to flip the flag after24 invoking. This will allow some uses that are potentially dangerous but25 should probably be permitted.26- Fixed Python 3 bug when a handler from `app.url_build_error_handlers`27 reraises the `BuildError`.2829Version 0.10.130--------------31
457 unmodified lines