From b549a7fcc5f8bf2bea6c689dd58e67a7de6e4aae Mon Sep 17 00:00:00 2001 From: Emmanuel Leroy Date: Mon, 15 Mar 2021 17:28:25 -0700 Subject: [PATCH 1/2] deprecated Python 2.x --- .travis.yml | 3 +-- drf_ujson/parsers.py | 6 +++--- drf_ujson/renderers.py | 5 +---- setup.py | 2 +- 4 files changed, 6 insertions(+), 10 deletions(-) diff --git a/.travis.yml b/.travis.yml index d9b9ccb..1eba21f 100644 --- a/.travis.yml +++ b/.travis.yml @@ -1,7 +1,6 @@ language: python python: - - "2.7" - - "3.3" + - "3.8" install: - pip install -r test_requirements.txt - pip install . --use-mirrors diff --git a/drf_ujson/parsers.py b/drf_ujson/parsers.py index 9e153ee..18942f1 100644 --- a/drf_ujson/parsers.py +++ b/drf_ujson/parsers.py @@ -2,8 +2,8 @@ from __future__ import unicode_literals from django.conf import settings -from rest_framework.compat import six -from rest_framework.parsers import BaseParser, ParseError +from rest_framework.parsers import BaseParser +from rest_framework.exceptions import ParseError from rest_framework.renderers import JSONRenderer import ujson @@ -31,4 +31,4 @@ def parse(self, stream, media_type=None, parser_context=None): data = stream.read().decode(encoding) return ujson.loads(data) except ValueError as exc: - raise ParseError('JSON parse error - %s' % six.text_type(exc)) + raise ParseError('JSON parse error - %s' % str(exc)) diff --git a/drf_ujson/renderers.py b/drf_ujson/renderers.py index 87b7b66..73b604c 100644 --- a/drf_ujson/renderers.py +++ b/drf_ujson/renderers.py @@ -1,5 +1,4 @@ from __future__ import unicode_literals -from rest_framework.compat import six from rest_framework.renderers import BaseRenderer import ujson @@ -22,8 +21,6 @@ def render(self, data, *args, **kwargs): return bytes() ret = ujson.dumps(data, ensure_ascii=self.ensure_ascii) - - # force return value to unicode - if isinstance(ret, six.text_type): + if isinstance(ret, str): return bytes(ret.encode('utf-8')) return ret diff --git a/setup.py b/setup.py index ba4e693..c69459d 100755 --- a/setup.py +++ b/setup.py @@ -4,7 +4,7 @@ setup( name='drf_ujson', - version='1.2', + version='2.0', description='Django Rest Framework UJSON Renderer', author='Gizmag', author_email='tech@gizmag.com', From 94ee5aa0f92c1ad47f7ee88da02e7982b32d451e Mon Sep 17 00:00:00 2001 From: Emmanuel Leroy Date: Mon, 15 Mar 2021 17:33:19 -0700 Subject: [PATCH 2/2] fix deprecated pip install in travis --- .travis.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.travis.yml b/.travis.yml index 1eba21f..7317bec 100644 --- a/.travis.yml +++ b/.travis.yml @@ -3,5 +3,5 @@ python: - "3.8" install: - pip install -r test_requirements.txt - - pip install . --use-mirrors + - pip install . script: nosetests