Commit ebc773ad authored by Claude Paroz's avatar Claude Paroz
Browse files

Replaced many smart_bytes by force_bytes

In all those occurrences, we didn't care about preserving the
lazy status of the strings, but we really wanted to obtain a
real bytestring.
parent 9eafb659
Loading
Loading
Loading
Loading
+2 −2
Original line number Diff line number Diff line
@@ -12,7 +12,7 @@ from django.utils import formats
from django.utils.html import format_html
from django.utils.text import capfirst
from django.utils import timezone
from django.utils.encoding import force_text, smart_text, smart_bytes
from django.utils.encoding import force_str, force_text, smart_text
from django.utils import six
from django.utils.translation import ungettext
from django.core.urlresolvers import reverse
@@ -277,7 +277,7 @@ def label_for_field(name, model, model_admin=None, return_attr=False):
            label = force_text(model._meta.verbose_name)
            attr = six.text_type
        elif name == "__str__":
            label = smart_bytes(model._meta.verbose_name)
            label = force_str(model._meta.verbose_name)
            attr = bytes
        else:
            if callable(name):
+2 −2
Original line number Diff line number Diff line
@@ -6,7 +6,7 @@ from django.core.paginator import InvalidPage
from django.db import models
from django.db.models.fields import FieldDoesNotExist
from django.utils.datastructures import SortedDict
from django.utils.encoding import force_text, smart_bytes
from django.utils.encoding import force_str, force_text
from django.utils.translation import ugettext, ugettext_lazy
from django.utils.http import urlencode

@@ -94,7 +94,7 @@ class ChangeList(object):
                # 'key' will be used as a keyword argument later, so Python
                # requires it to be a string.
                del lookup_params[key]
                lookup_params[smart_bytes(key)] = value
                lookup_params[force_str(key)] = value

            if not self.model_admin.lookup_allowed(key, value):
                raise SuspiciousOperation("Filtering by %s not allowed" % key)
+2 −2
Original line number Diff line number Diff line
@@ -6,7 +6,7 @@ from email.errors import HeaderParseError

from django.utils.safestring import mark_safe
from django.core.urlresolvers import reverse
from django.utils.encoding import smart_bytes
from django.utils.encoding import force_bytes
try:
    import docutils.core
    import docutils.nodes
@@ -66,7 +66,7 @@ def parse_rst(text, default_reference_context, thing_being_parsed=None):
        "link_base" : reverse('django-admindocs-docroot').rstrip('/')
    }
    if thing_being_parsed:
        thing_being_parsed = smart_bytes("<%s>" % thing_being_parsed)
        thing_being_parsed = force_bytes("<%s>" % thing_being_parsed)
    parts = docutils.core.publish_parts(text, source_path=thing_being_parsed,
                destination_path=None, writer_name='html',
                settings_overrides=overrides)
+4 −4
Original line number Diff line number Diff line
@@ -8,7 +8,7 @@ from django.conf import settings
from django.test.signals import setting_changed
from django.utils import importlib
from django.utils.datastructures import SortedDict
from django.utils.encoding import smart_bytes
from django.utils.encoding import force_bytes
from django.core.exceptions import ImproperlyConfigured
from django.utils.crypto import (
    pbkdf2, constant_time_compare, get_random_string)
@@ -299,7 +299,7 @@ class SHA1PasswordHasher(BasePasswordHasher):
    def encode(self, password, salt):
        assert password
        assert salt and '$' not in salt
        hash = hashlib.sha1(smart_bytes(salt + password)).hexdigest()
        hash = hashlib.sha1(force_bytes(salt + password)).hexdigest()
        return "%s$%s$%s" % (self.algorithm, salt, hash)

    def verify(self, password, encoded):
@@ -327,7 +327,7 @@ class MD5PasswordHasher(BasePasswordHasher):
    def encode(self, password, salt):
        assert password
        assert salt and '$' not in salt
        hash = hashlib.md5(smart_bytes(salt + password)).hexdigest()
        hash = hashlib.md5(force_bytes(salt + password)).hexdigest()
        return "%s$%s$%s" % (self.algorithm, salt, hash)

    def verify(self, password, encoded):
@@ -361,7 +361,7 @@ class UnsaltedMD5PasswordHasher(BasePasswordHasher):
        return ''

    def encode(self, password, salt):
        return hashlib.md5(smart_bytes(password)).hexdigest()
        return hashlib.md5(force_bytes(password)).hexdigest()

    def verify(self, password, encoded):
        encoded_2 = self.encode(password, '')
+1 −2
Original line number Diff line number Diff line
@@ -8,7 +8,6 @@ from django.core.paginator import EmptyPage, PageNotAnInteger
from django.contrib.gis.db.models.fields import GeometryField
from django.db import connections, DEFAULT_DB_ALIAS
from django.db.models import get_model
from django.utils.encoding import smart_bytes
from django.utils import six
from django.utils.translation import ugettext as _

@@ -61,7 +60,7 @@ def sitemap(request, sitemaps, section=None):
            raise Http404(_("Page %s empty") % page)
        except PageNotAnInteger:
            raise Http404(_("No page '%s'") % page)
    xml = smart_bytes(loader.render_to_string('gis/sitemaps/geo_sitemap.xml', {'urlset': urls}))
    xml = loader.render_to_string('gis/sitemaps/geo_sitemap.xml', {'urlset': urls})
    return HttpResponse(xml, content_type='application/xml')

def kml(request, label, model, field_name=None, compress=False, using=DEFAULT_DB_ALIAS):
Loading