Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

[py3] Made __repr__ return str with Python 3

  • Loading branch information...
commit dce34dc9696734f7ca02d410ddac69d714a25f1e 1 parent c1684e3
Claude Paroz claudep authored
12 django/contrib/databrowse/datastructures.py
View
@@ -7,7 +7,7 @@
from django.db import models
from django.utils import formats
from django.utils.text import capfirst
-from django.utils.encoding import smart_text, smart_bytes, iri_to_uri
+from django.utils.encoding import smart_text, smart_str, iri_to_uri
from django.db.models.query import QuerySet
from django.utils.encoding import python_2_unicode_compatible
@@ -23,7 +23,7 @@ def __init__(self, site, model):
self.verbose_name_plural = model._meta.verbose_name_plural
def __repr__(self):
- return '<EasyModel for %s>' % smart_bytes(self.model._meta.object_name)
+ return smart_str('<EasyModel for %s>' % self.model._meta.object_name)
def model_databrowse(self):
"Returns the ModelDatabrowse class for this model."
@@ -62,7 +62,7 @@ def __init__(self, easy_model, field):
self.model, self.field = easy_model, field
def __repr__(self):
- return smart_bytes('<EasyField for %s.%s>' % (self.model.model._meta.object_name, self.field.name))
+ return smart_str('<EasyField for %s.%s>' % (self.model.model._meta.object_name, self.field.name))
def choices(self):
for value, label in self.field.choices:
@@ -80,7 +80,7 @@ def __init__(self, easy_model, field, value, label):
self.value, self.label = value, label
def __repr__(self):
- return smart_bytes('<EasyChoice for %s.%s>' % (self.model.model._meta.object_name, self.field.name))
+ return smart_str('<EasyChoice for %s.%s>' % (self.model.model._meta.object_name, self.field.name))
def url(self):
return '%s%s/%s/%s/%s/' % (self.model.site.root_url, self.model.model._meta.app_label, self.model.model._meta.module_name, self.field.field.name, iri_to_uri(self.value))
@@ -91,7 +91,7 @@ def __init__(self, easy_model, instance):
self.model, self.instance = easy_model, instance
def __repr__(self):
- return smart_bytes('<EasyInstance for %s (%s)>' % (self.model.model._meta.object_name, self.instance._get_pk_val()))
+ return smart_str('<EasyInstance for %s (%s)>' % (self.model.model._meta.object_name, self.instance._get_pk_val()))
def __str__(self):
val = smart_text(self.instance)
@@ -135,7 +135,7 @@ def __init__(self, easy_model, instance, field):
self.raw_value = getattr(instance.instance, field.name)
def __repr__(self):
- return smart_bytes('<EasyInstanceField for %s.%s>' % (self.model.model._meta.object_name, self.field.name))
+ return smart_str('<EasyInstanceField for %s.%s>' % (self.model.model._meta.object_name, self.field.name))
def values(self):
"""
4 django/core/files/uploadedfile.py
View
@@ -8,7 +8,7 @@
from django.conf import settings
from django.core.files.base import File
from django.core.files import temp as tempfile
-from django.utils.encoding import smart_bytes
+from django.utils.encoding import smart_str
__all__ = ('UploadedFile', 'TemporaryUploadedFile', 'InMemoryUploadedFile',
'SimpleUploadedFile')
@@ -30,7 +30,7 @@ def __init__(self, file=None, name=None, content_type=None, size=None, charset=N
self.charset = charset
def __repr__(self):
- return smart_bytes("<%s: %s (%s)>" % (
+ return smart_str("<%s: %s (%s)>" % (
self.__class__.__name__, self.name, self.content_type))
def _get_name(self):
8 django/core/urlresolvers.py
View
@@ -14,7 +14,7 @@
from django.http import Http404
from django.core.exceptions import ImproperlyConfigured, ViewDoesNotExist
from django.utils.datastructures import MultiValueDict
-from django.utils.encoding import iri_to_uri, force_text, smart_bytes
+from django.utils.encoding import iri_to_uri, force_text, smart_str
from django.utils.functional import memoize, lazy
from django.utils.importlib import import_module
from django.utils.module_loading import module_has_submodule
@@ -190,7 +190,7 @@ def __init__(self, regex, callback, default_args=None, name=None):
self.name = name
def __repr__(self):
- return smart_bytes('<%s %s %s>' % (self.__class__.__name__, self.name, self.regex.pattern))
+ return smart_str('<%s %s %s>' % (self.__class__.__name__, self.name, self.regex.pattern))
def add_prefix(self, prefix):
"""
@@ -240,7 +240,9 @@ def __init__(self, regex, urlconf_name, default_kwargs=None, app_name=None, name
self._app_dict = {}
def __repr__(self):
- return smart_bytes('<%s %s (%s:%s) %s>' % (self.__class__.__name__, self.urlconf_name, self.app_name, self.namespace, self.regex.pattern))
+ return smart_str('<%s %s (%s:%s) %s>' % (
+ self.__class__.__name__, self.urlconf_name, self.app_name,
+ self.namespace, self.regex.pattern))
def _populate(self):
lookups = MultiValueDict()
4 django/db/models/base.py
View
@@ -23,7 +23,7 @@
from django.db.models.loading import register_models, get_model
from django.utils.translation import ugettext_lazy as _
from django.utils.functional import curry
-from django.utils.encoding import smart_bytes, force_text
+from django.utils.encoding import smart_bytes, smart_str, force_text
from django.utils import six
from django.utils.text import get_text_list, capfirst
@@ -404,7 +404,7 @@ def __repr__(self):
u = six.text_type(self)
except (UnicodeEncodeError, UnicodeDecodeError):
u = '[Bad Unicode data]'
- return smart_bytes('<%s: %s>' % (self.__class__.__name__, u))
+ return smart_str('<%s: %s>' % (self.__class__.__name__, u))
def __str__(self):
if not six.PY3 and hasattr(self, '__unicode__'):
4 django/template/base.py
View
@@ -11,7 +11,7 @@
from django.utils.itercompat import is_iterable
from django.utils.text import (smart_split, unescape_string_literal,
get_text_list)
-from django.utils.encoding import smart_text, force_text, smart_bytes
+from django.utils.encoding import smart_text, force_text, smart_str
from django.utils.translation import ugettext_lazy, pgettext_lazy
from django.utils.safestring import (SafeData, EscapeData, mark_safe,
mark_for_escaping)
@@ -848,7 +848,7 @@ def __init__(self, s):
self.s = s
def __repr__(self):
- return "<Text Node: '%s'>" % smart_bytes(self.s[:25], 'ascii',
+ return "<Text Node: '%s'>" % smart_str(self.s[:25], 'ascii',
errors='replace')
def render(self, context):
Please sign in to comment.
Something went wrong with that request. Please try again.