Commit bdca5ea3 authored by Aymeric Augustin's avatar Aymeric Augustin
Browse files

[py3] Replaced unicode/str by six.text_type/bytes.

parent 3cb2457f
Loading
Loading
Loading
Loading
+1 −1
Original line number Diff line number Diff line
@@ -189,7 +189,7 @@ class AdminReadonlyField(object):
                if value is None:
                    result_repr = EMPTY_CHANGELIST_VALUE
                elif isinstance(f.rel, ManyToManyRel):
                    result_repr = ", ".join(map(unicode, value.all()))
                    result_repr = ", ".join(map(six.text_type, value.all()))
                else:
                    result_repr = display_for_field(value, f)
        return conditional_escape(result_repr)
+2 −2
Original line number Diff line number Diff line
@@ -275,10 +275,10 @@ def label_for_field(name, model, model_admin=None, return_attr=False):
    except models.FieldDoesNotExist:
        if name == "__unicode__":
            label = force_unicode(model._meta.verbose_name)
            attr = unicode
            attr = six.text_type
        elif name == "__str__":
            label = smart_str(model._meta.verbose_name)
            attr = str
            attr = bytes
        else:
            if callable(name):
                attr = name
+2 −1
Original line number Diff line number Diff line
@@ -15,6 +15,7 @@ from django.utils.text import Truncator
from django.utils.translation import ugettext as _
from django.utils.safestring import mark_safe
from django.utils.encoding import force_unicode
from django.utils import six


class FilteredSelectMultiple(forms.SelectMultiple):
@@ -121,7 +122,7 @@ def url_params_from_lookup_dict(lookups):
                # See django.db.fields.BooleanField.get_prep_lookup
                v = ('0', '1')[v]
            else:
                v = unicode(v)
                v = six.text_type(v)
            items.append((k, v))
        params.update(dict(items))
    return params
+5 −4
Original line number Diff line number Diff line
@@ -8,6 +8,7 @@ from django.db import models
from django.db.models.manager import EmptyManager
from django.utils.crypto import get_random_string
from django.utils.encoding import smart_str
from django.utils import six
from django.utils.translation import ugettext_lazy as _
from django.utils import timezone

@@ -79,9 +80,9 @@ class Permission(models.Model):

    def __unicode__(self):
        return "%s | %s | %s" % (
            unicode(self.content_type.app_label),
            unicode(self.content_type),
            unicode(self.name))
            six.text_type(self.content_type.app_label),
            six.text_type(self.content_type),
            six.text_type(self.name))

    def natural_key(self):
        return (self.codename,) + self.content_type.natural_key()
@@ -421,7 +422,7 @@ class AnonymousUser(object):
        return 'AnonymousUser'

    def __str__(self):
        return unicode(self).encode('utf-8')
        return six.text_type(self).encode('utf-8')

    def __eq__(self, other):
        return isinstance(other, self.__class__)
+3 −2
Original line number Diff line number Diff line
@@ -2,6 +2,7 @@ from datetime import date
from django.conf import settings
from django.utils.http import int_to_base36, base36_to_int
from django.utils.crypto import constant_time_compare, salted_hmac
from django.utils import six

class PasswordResetTokenGenerator(object):
    """
@@ -56,8 +57,8 @@ class PasswordResetTokenGenerator(object):
        # Ensure results are consistent across DB backends
        login_timestamp = user.last_login.replace(microsecond=0, tzinfo=None)

        value = (unicode(user.id) + user.password +
                unicode(login_timestamp) + unicode(timestamp))
        value = (six.text_type(user.id) + user.password +
                six.text_type(login_timestamp) + six.text_type(timestamp))
        hash = salted_hmac(key_salt, value).hexdigest()[::2]
        return "%s-%s" % (ts_b36, hash)

Loading