Skip to content

Commit

Permalink
clean up
Browse files Browse the repository at this point in the history
  • Loading branch information
davidism committed Jan 26, 2016
1 parent 7df543d commit 992d9be
Showing 1 changed file with 6 additions and 11 deletions.
17 changes: 6 additions & 11 deletions flask/json.py
Original file line number Diff line number Diff line change
Expand Up @@ -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):
Expand Down Expand Up @@ -251,26 +251,21 @@ def get_current_user():
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):
Expand Down

0 comments on commit 992d9be

Please sign in to comment.