From 1b23543ed1f0dea903cd128662e8fba7428edbcc Mon Sep 17 00:00:00 2001 From: Sebastian Pipping Date: Thu, 31 Oct 2019 12:24:36 +0100 Subject: [PATCH] parsers: Pull parse_constant out of try-except block --- rest_framework/parsers.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/rest_framework/parsers.py b/rest_framework/parsers.py index fc4eb1428..79ea5133f 100644 --- a/rest_framework/parsers.py +++ b/rest_framework/parsers.py @@ -56,12 +56,12 @@ class JSONParser(BaseParser): """ Parses the incoming bytestream as JSON and returns the resulting data. """ + parse_constant = json.strict_constant if self.strict else None parser_context = parser_context or {} encoding = parser_context.get('encoding', settings.DEFAULT_CHARSET) try: decoded_stream = codecs.getreader(encoding)(stream) - parse_constant = json.strict_constant if self.strict else None return json.load(decoded_stream, parse_constant=parse_constant) except ValueError as exc: raise ParseError('JSON parse error - %s' % str(exc))