Skip to content

Commit 16df96c

Browse files
committed
Merge branch 'master' into sprint-branch
2 parents 79ec3d8 + 4c27f7a commit 16df96c

File tree

6 files changed

+17
-74
lines changed

6 files changed

+17
-74
lines changed

CHANGES

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -54,6 +54,9 @@ Release date to be decided.
5454
- Added `message_flashed` signal that simplifies flashing testing.
5555
- Added support for copying of request contexts for better working with
5656
greenlets.
57+
- Removed custom JSON HTTP exception subclasses. If you were relying on them
58+
you can reintroduce them again yourself trivially. Using them however is
59+
strongly discouraged as the interface was flawed.
5760
- Python requirements changed: requiring Python 2.6 or 2.7 now to prepare
5861
for Python 3.3 port.
5962

flask/ctx.py

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,8 @@
99
:license: BSD, see LICENSE for more details.
1010
"""
1111

12+
from __future__ import with_statement
13+
1214
import sys
1315
from functools import update_wrapper
1416

flask/exceptions.py

Lines changed: 0 additions & 48 deletions
This file was deleted.

flask/json.py

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,10 @@
1717

1818
# Use the same json implementation as itsdangerous on which we
1919
# depend anyways.
20-
from itsdangerous import json as _json
20+
try:
21+
from itsdangerous import simplejson as _json
22+
except ImportError:
23+
from itsdangerous import json as _json
2124

2225

2326
# figure out if simplejson escapes slashes. This behavior was changed

flask/testsuite/helpers.py

Lines changed: 1 addition & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -33,23 +33,11 @@ def test_json_bad_requests(self):
3333
app = flask.Flask(__name__)
3434
@app.route('/json', methods=['POST'])
3535
def return_json():
36-
return text_type(flask.request.json)
36+
return flask.jsonify(foo=text_type(flask.request.json))
3737
c = app.test_client()
3838
rv = c.post('/json', data='malformed', content_type='application/json')
3939
self.assert_equal(rv.status_code, 400)
4040

41-
def test_json_bad_requests_content_type(self):
42-
app = flask.Flask(__name__)
43-
@app.route('/json', methods=['POST'])
44-
def return_json():
45-
return text_type(flask.request.json)
46-
c = app.test_client()
47-
rv = c.post('/json', data='malformed', content_type='application/json')
48-
self.assert_equal(rv.status_code, 400)
49-
self.assert_equal(rv.mimetype, 'application/json')
50-
self.assert_in('description', flask.json.loads(rv.data))
51-
self.assert_not_in('<p>', flask.json.loads(rv.data)['description'])
52-
5341
def test_json_body_encoding(self):
5442
app = flask.Flask(__name__)
5543
app.testing = True

flask/wrappers.py

Lines changed: 7 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -11,8 +11,8 @@
1111

1212
from werkzeug.wrappers import Request as RequestBase, Response as ResponseBase
1313
from werkzeug.utils import cached_property
14+
from werkzeug.exceptions import BadRequest
1415

15-
from .exceptions import JSONBadRequest
1616
from .debughelpers import attach_enctype_error_multidict
1717
from . import json
1818
from .globals import _request_ctx_stack
@@ -105,21 +105,16 @@ def json(self):
105105
def on_json_loading_failed(self, e):
106106
"""Called if decoding of the JSON data failed. The return value of
107107
this method is used by :attr:`json` when an error occurred. The default
108-
implementation raises a :class:`JSONBadRequest`, which is a subclass of
109-
:class:`~werkzeug.exceptions.BadRequest` which sets the
110-
``Content-Type`` to ``application/json`` and provides a JSON-formatted
111-
error description::
108+
implementation just raises a :class:`BadRequest` exception.
112109
113-
{"description": "The browser (or proxy) sent a request that \
114-
this server could not understand."}
115-
116-
.. versionchanged:: 0.9
117-
Return a :class:`JSONBadRequest` instead of a
118-
:class:`~werkzeug.exceptions.BadRequest` by default.
110+
.. versionchanged:: 0.10
111+
Removed buggy previous behavior of generating a random JSON
112+
response. If you want that behavior back you can trivially
113+
add it by subclassing.
119114
120115
.. versionadded:: 0.8
121116
"""
122-
raise JSONBadRequest()
117+
raise BadRequest()
123118

124119
def _load_form_data(self):
125120
RequestBase._load_form_data(self)

0 commit comments

Comments
 (0)