From 992d9be96ef0f0d746bd4a77b9081bff3b44524b Mon Sep 17 00:00:00 2001 From: David Lord Date: Mon, 25 Jan 2016 22:56:51 -0800 Subject: [PATCH] clean up --- flask/json.py | 17 ++++++----------- 1 file changed, 6 insertions(+), 11 deletions(-) diff --git a/flask/json.py b/flask/json.py index a8eb5922..cfc28c53 100644 --- a/flask/json.py +++ b/flask/json.py @@ -195,7 +195,7 @@ def htmlsafe_dumps(obj, **kwargs): def htmlsafe_dump(obj, fp, **kwargs): """Like :func:`htmlsafe_dumps` but writes into a file object.""" - fp.write(unicode(htmlsafe_dumps(obj, **kwargs))) + fp.write(text_type(htmlsafe_dumps(obj, **kwargs))) def jsonify(*args, **kwargs): @@ -251,26 +251,21 @@ def jsonify(*args, **kwargs): indent = None separators = (',', ':') - if current_app.config['JSONIFY_PRETTYPRINT_REGULAR'] \ - and not request.is_xhr: + if current_app.config['JSONIFY_PRETTYPRINT_REGULAR'] and not request.is_xhr: indent = 2 separators = (', ', ': ') if args and kwargs: - raise TypeError( - "jsonify() behavior undefined when passed both args and kwargs" - ) + raise TypeError('jsonify() behavior undefined when passed both args and kwargs') elif len(args) == 1: # single args are passed directly to dumps() data = args[0] else: data = args or kwargs - # Note that we add '\n' to end of response - # (see https://github.com/mitsuhiko/flask/pull/1262) - rv = current_app.response_class( + return current_app.response_class( (dumps(data, indent=indent, separators=separators), '\n'), - mimetype='application/json') - return rv + mimetype='application/json' + ) def tojson_filter(obj, **kwargs):