From 12253ab757538312b1adcc37998fbc2910090394 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Leonel=20C=C3=A2mara?= Date: Mon, 13 Nov 2017 15:31:05 +0000 Subject: [PATCH] Fix #1715 --- gluon/globals.py | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/gluon/globals.py b/gluon/globals.py index cb52d331..b4344f0f 100644 --- a/gluon/globals.py +++ b/gluon/globals.py @@ -220,7 +220,12 @@ class Request(Storage): if is_json: try: - json_vars = json_parser.load(body) + # In Python 3 versions prior to 3.6 load doesn't accept bytes and + # bytearray, so we read the body convert to native and use loads + # instead of load. + # This line can be simplified to json_vars = json_parser.load(body) + # if and when we drop support for python versions under 3.6 + json_vars = json_parser.loads(to_native(body.read())) except: # incoherent request bodies can still be parsed "ad-hoc" json_vars = {}