Skip to content

Commit 426547c

Browse files
committed
str() -> six.text_type(). Closes #2290.
1 parent 65fc0d0 commit 426547c

File tree

2 files changed

+12
-10
lines changed

2 files changed

+12
-10
lines changed

rest_framework/exceptions.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,8 +5,8 @@
55
(`django.http.Http404` and `django.core.exceptions.PermissionDenied`)
66
"""
77
from __future__ import unicode_literals
8+
from django.utils import six
89
from django.utils.encoding import force_text
9-
1010
from django.utils.translation import ugettext_lazy as _
1111
from django.utils.translation import ungettext_lazy
1212
from rest_framework import status
@@ -66,7 +66,7 @@ def __init__(self, detail):
6666
self.detail = _force_text_recursive(detail)
6767

6868
def __str__(self):
69-
return str(self.detail)
69+
return six.text_type(self.detail)
7070

7171

7272
class ParseError(APIException):

rest_framework/relations.py

Lines changed: 10 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,15 @@
1-
from django.utils.encoding import smart_text
2-
from rest_framework.fields import get_attribute, empty, Field
3-
from rest_framework.reverse import reverse
4-
from rest_framework.utils import html
1+
# coding: utf-8
2+
from __future__ import unicode_literals
53
from django.core.exceptions import ObjectDoesNotExist, ImproperlyConfigured
64
from django.core.urlresolvers import resolve, get_script_prefix, NoReverseMatch, Resolver404
75
from django.db.models.query import QuerySet
86
from django.utils import six
7+
from django.utils.encoding import smart_text
98
from django.utils.six.moves.urllib import parse as urlparse
109
from django.utils.translation import ugettext_lazy as _
10+
from rest_framework.fields import get_attribute, empty, Field
11+
from rest_framework.reverse import reverse
12+
from rest_framework.utils import html
1113

1214

1315
class PKOnlyObject(object):
@@ -103,8 +105,8 @@ def get_attribute(self, instance):
103105
def choices(self):
104106
return dict([
105107
(
106-
str(self.to_representation(item)),
107-
str(item)
108+
six.text_type(self.to_representation(item)),
109+
six.text_type(item)
108110
)
109111
for item in self.queryset.all()
110112
])
@@ -364,8 +366,8 @@ def choices(self):
364366
]
365367
return dict([
366368
(
367-
str(item_representation),
368-
str(item) + ' - ' + str(item_representation)
369+
six.text_type(item_representation),
370+
six.text_type(item) + ' - ' + six.text_type(item_representation)
369371
)
370372
for item, item_representation in items_and_representations
371373
])

0 commit comments

Comments
 (0)