From 6c99a60e0d8b457720227540846982cee1bb7c45 Mon Sep 17 00:00:00 2001 From: Malcolm Tredinnick Date: Mon, 14 May 2007 07:04:31 +0000 Subject: [PATCH] unicode: Made various changes to prevent actual and potential Python 2.3 compatibility problems. Refs #3582. git-svn-id: http://code.djangoproject.com/svn/django/branches/unicode@5223 bcc190cf-cafb-0310-a4f2-bffc1f526a37 --- django/db/models/base.py | 2 +- django/newforms/util.py | 8 ++++---- django/newforms/widgets.py | 2 +- django/template/defaultfilters.py | 8 ++++---- django/utils/html.py | 12 +++++++----- 5 files changed, 17 insertions(+), 15 deletions(-) diff --git a/django/db/models/base.py b/django/db/models/base.py index 645ee7eb95..99e57e44c6 100644 --- a/django/db/models/base.py +++ b/django/db/models/base.py @@ -84,7 +84,7 @@ class Model(object): return getattr(self, self._meta.pk.attname) def __repr__(self): - return smart_str(u'<%s: %s>' % (self.__class__.__name__, self)) + return smart_str(u'<%s: %s>' % (self.__class__.__name__, unicode(self))) def __str__(self): if hasattr(self, '__unicode__'): diff --git a/django/newforms/util.py b/django/newforms/util.py index 5fc0223f5b..fae2c860a9 100644 --- a/django/newforms/util.py +++ b/django/newforms/util.py @@ -18,10 +18,10 @@ class ErrorDict(dict): def as_ul(self): if not self: return u'' - return u'' % ''.join([u'
  • %s%s
  • ' % (k, v) for k, v in self.items()]) + return u'' % ''.join([u'
  • %s%s
  • ' % (k, smart_unicode(v)) for k, v in self.items()]) def as_text(self): - return u'\n'.join([u'* %s\n%s' % (k, u'\n'.join([u' * %s' % i for i in v])) for k, v in self.items()]) + return u'\n'.join([u'* %s\n%s' % (k, u'\n'.join([u' * %s' % smart_unicode(i) for i in v])) for k, v in self.items()]) class ErrorList(list): """ @@ -32,11 +32,11 @@ class ErrorList(list): def as_ul(self): if not self: return u'' - return u'' % ''.join([u'
  • %s
  • ' % e for e in self]) + return u'' % ''.join([u'
  • %s
  • ' % smart_unicode(e) for e in self]) def as_text(self): if not self: return u'' - return u'\n'.join([u'* %s' % e for e in self]) + return u'\n'.join([u'* %s' % smart_unicode(e) for e in self]) class ValidationError(Exception): def __init__(self, message): diff --git a/django/newforms/widgets.py b/django/newforms/widgets.py index dd71ebc455..a726ebf894 100644 --- a/django/newforms/widgets.py +++ b/django/newforms/widgets.py @@ -253,7 +253,7 @@ class RadioFieldRenderer(StrAndUnicode): def __unicode__(self): "Outputs a