forked from orbit-oss/flask
Merge branch 'lobeck-fix_unboundlocalerror_for_handle_build_error' into 0.10-maintenance
Fix #1533
This commit is contained in:
commit
6a6a6d87c2
3 changed files with 16 additions and 2 deletions
2
CHANGES
2
CHANGES
|
|
@ -23,6 +23,8 @@ Version 0.10.2
|
||||||
- Changed logic of before first request handlers to flip the flag after
|
- Changed logic of before first request handlers to flip the flag after
|
||||||
invoking. This will allow some uses that are potentially dangerous but
|
invoking. This will allow some uses that are potentially dangerous but
|
||||||
should probably be permitted.
|
should probably be permitted.
|
||||||
|
- Fixed Python 3 bug when a handler from `app.url_build_error_handlers`
|
||||||
|
reraises the `BuildError`.
|
||||||
|
|
||||||
Version 0.10.1
|
Version 0.10.1
|
||||||
--------------
|
--------------
|
||||||
|
|
|
||||||
|
|
@ -1631,8 +1631,9 @@ class Flask(_PackageBoundObject):
|
||||||
rv = handler(error, endpoint, values)
|
rv = handler(error, endpoint, values)
|
||||||
if rv is not None:
|
if rv is not None:
|
||||||
return rv
|
return rv
|
||||||
except BuildError as error:
|
except BuildError as e:
|
||||||
pass
|
# make error available outside except block (py3)
|
||||||
|
error = e
|
||||||
|
|
||||||
# At this point we want to reraise the exception. If the error is
|
# At this point we want to reraise the exception. If the error is
|
||||||
# still the same one we can reraise it with the original traceback,
|
# still the same one we can reraise it with the original traceback,
|
||||||
|
|
|
||||||
|
|
@ -772,6 +772,17 @@ class BasicFunctionalityTestCase(FlaskTestCase):
|
||||||
with app.test_request_context():
|
with app.test_request_context():
|
||||||
self.assert_equal(flask.url_for('spam'), '/test_handler/')
|
self.assert_equal(flask.url_for('spam'), '/test_handler/')
|
||||||
|
|
||||||
|
def test_build_error_handler_reraise(self):
|
||||||
|
app = flask.Flask(__name__)
|
||||||
|
|
||||||
|
# Test a custom handler which reraises the BuildError
|
||||||
|
def handler_raises_build_error(error, endpoint, values):
|
||||||
|
raise error
|
||||||
|
app.url_build_error_handlers.append(handler_raises_build_error)
|
||||||
|
|
||||||
|
with app.test_request_context():
|
||||||
|
self.assertRaises(BuildError, flask.url_for, 'not.existing')
|
||||||
|
|
||||||
def test_custom_converters(self):
|
def test_custom_converters(self):
|
||||||
from werkzeug.routing import BaseConverter
|
from werkzeug.routing import BaseConverter
|
||||||
class ListConverter(BaseConverter):
|
class ListConverter(BaseConverter):
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue