Browse Source

Added Python3.6 check for json.loads

pull/2262/head
Ayush Kohli 8 years ago
parent
commit
449024c20b
  1. 3
      flask/_compat.py
  2. 7
      flask/json.py

3
flask/_compat.py

@ -13,6 +13,9 @@
import sys
PY2 = sys.version_info[0] == 2
PY3.6 = sys.version_info[0] == 3 and sys.version_info[1] == 6
_identity = lambda x: x

7
flask/json.py

@ -12,7 +12,7 @@ import io
import uuid
from datetime import date
from .globals import current_app, request
from ._compat import text_type, PY2
from ._compat import text_type, PY2, PY3.6
from .ctx import has_request_context
from werkzeug.http import http_date
@ -154,8 +154,9 @@ def loads(s, **kwargs):
application on the stack.
"""
_load_arg_defaults(kwargs)
if isinstance(s, bytes):
s = s.decode(kwargs.pop('encoding', None) or 'utf-8')
if not PY3.6:
if isinstance(s, bytes):
s = s.decode(kwargs.pop('encoding', None) or 'utf-8')
return _json.loads(s, **kwargs)

Loading…
Cancel
Save