From 449024c20be9a80c5b57c0db00e40bf2cba37530 Mon Sep 17 00:00:00 2001 From: Ayush Kohli Date: Fri, 28 Apr 2017 18:20:50 -0500 Subject: [PATCH] Added Python3.6 check for json.loads --- flask/_compat.py | 3 +++ flask/json.py | 7 ++++--- 2 files changed, 7 insertions(+), 3 deletions(-) diff --git a/flask/_compat.py b/flask/_compat.py index 071628fc..eaf42ea2 100644 --- a/flask/_compat.py +++ b/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 diff --git a/flask/json.py b/flask/json.py index bf8a8843..6690de34 100644 --- a/flask/json.py +++ b/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)