Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

deprecated Python 2.x #16

Open
wants to merge 2 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 2 additions & 3 deletions .travis.yml
Original file line number Diff line number Diff line change
@@ -1,8 +1,7 @@
language: python
python:
- "2.7"
- "3.3"
- "3.8"
install:
- pip install -r test_requirements.txt
- pip install . --use-mirrors
- pip install .
script: nosetests
6 changes: 3 additions & 3 deletions drf_ujson/parsers.py
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand Down Expand Up @@ -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))
5 changes: 1 addition & 4 deletions drf_ujson/renderers.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
from __future__ import unicode_literals
from rest_framework.compat import six
from rest_framework.renderers import BaseRenderer
import ujson

Expand All @@ -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
2 changes: 1 addition & 1 deletion setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@

setup(
name='drf_ujson',
version='1.2',
version='2.0',
description='Django Rest Framework UJSON Renderer',
author='Gizmag',
author_email='[email protected]',
Expand Down