From 709289037ae149444b18a59975cf9dc6e93cd05a Mon Sep 17 00:00:00 2001 From: Augustus D'Souza Date: Sat, 18 Oct 2014 13:14:04 +0530 Subject: [PATCH 1/4] Corrected api docs http://flask.pocoo.org/docs/0.10/api/#flask.Request.get_json --- flask/wrappers.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/flask/wrappers.py b/flask/wrappers.py index e77b9c20..038ba6fc 100644 --- a/flask/wrappers.py +++ b/flask/wrappers.py @@ -115,8 +115,8 @@ class Request(RequestBase): but this can be overriden by the `force` parameter. :param force: if set to `True` the mimetype is ignored. - :param silent: if set to `False` this method will fail silently - and return `False`. + :param silent: if set to `True` this method will fail silently + and return `None`. :param cache: if set to `True` the parsed JSON data is remembered on the request. """ From c60b5b91e282ce4984fef7cede1a058e66c420df Mon Sep 17 00:00:00 2001 From: Philip House Date: Sun, 1 Feb 2015 15:53:35 -0600 Subject: [PATCH 2/4] Update api.rst, fixed spelling --- docs/api.rst | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/docs/api.rst b/docs/api.rst index 48bb001e..272b193a 100644 --- a/docs/api.rst +++ b/docs/api.rst @@ -350,7 +350,7 @@ JSON Support Flask uses ``simplejson`` for the JSON implementation. Since simplejson is provided both by the standard library as well as extension Flask will try simplejson first and then fall back to the stdlib json module. On top -of that it will delegate access to the current application's JSOn encoders +of that it will delegate access to the current application's JSON encoders and decoders for easier customization. So for starters instead of doing:: From 5da31f8af36012a4f76c3bd0d536ae107e0519b5 Mon Sep 17 00:00:00 2001 From: Christian Becker Date: Wed, 15 Jul 2015 01:20:39 +0200 Subject: [PATCH 3/4] fix UnboundLocalError in handle_url_build_error - caused by changes in the execution model of python 3 where the alias of an except clause is cleared on exit of the except --- flask/app.py | 5 +++-- flask/testsuite/basic.py | 11 +++++++++++ 2 files changed, 14 insertions(+), 2 deletions(-) diff --git a/flask/app.py b/flask/app.py index cc3fc1d9..e073798a 100644 --- a/flask/app.py +++ b/flask/app.py @@ -1631,8 +1631,9 @@ class Flask(_PackageBoundObject): rv = handler(error, endpoint, values) if rv is not None: return rv - except BuildError as error: - pass + except BuildError as e: + # make error available outside except block (py3) + error = e # 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, diff --git a/flask/testsuite/basic.py b/flask/testsuite/basic.py index 31fade13..803a008c 100644 --- a/flask/testsuite/basic.py +++ b/flask/testsuite/basic.py @@ -772,6 +772,17 @@ class BasicFunctionalityTestCase(FlaskTestCase): with app.test_request_context(): 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): from werkzeug.routing import BaseConverter class ListConverter(BaseConverter): From 765f851a7c880fc654eada6aefb4ce7aa5b14525 Mon Sep 17 00:00:00 2001 From: Markus Unterwaditzer Date: Thu, 16 Jul 2015 12:01:25 +0200 Subject: [PATCH 4/4] Changelog for #1533 --- CHANGES | 2 ++ 1 file changed, 2 insertions(+) diff --git a/CHANGES b/CHANGES index a67937ff..89de874f 100644 --- a/CHANGES +++ b/CHANGES @@ -23,6 +23,8 @@ Version 0.10.2 - Changed logic of before first request handlers to flip the flag after invoking. This will allow some uses that are potentially dangerous but should probably be permitted. +- Fixed Python 3 bug when a handler from `app.url_build_error_handlers` + reraises the `BuildError`. Version 0.10.1 --------------