<?xml version="1.0" encoding="UTF-8"?>
<commit>
  <added type="array"/>
  <modified type="array">
    <modified>
      <diff>@@ -266,7 +266,11 @@ class Model(object):
         signals.post_init.send(sender=self.__class__, instance=self)
 
     def __repr__(self):
-        return smart_str(u'&lt;%s: %s&gt;' % (self.__class__.__name__, unicode(self)))
+        try:
+            u = unicode(self)
+        except (UnicodeEncodeError, UnicodeDecodeError):
+            u = '[Bad Unicode data]'
+        return smart_str(u'&lt;%s: %s&gt;' % (self.__class__.__name__, u))
 
     def __str__(self):
         if hasattr(self, '__unicode__'):</diff>
      <filename>django/db/models/base.py</filename>
    </modified>
    <modified>
      <diff>@@ -46,6 +46,12 @@ class Worker(models.Model):
     def __unicode__(self):
         return self.name
 
+class BrokenUnicodeMethod(models.Model):
+    name = models.CharField(max_length=7)
+    def __unicode__(self):
+        return 'N&#225;zov: %s' % self.name
+
+
 __test__ = {'API_TESTS': &quot;&quot;&quot;
 (NOTE: Part of the regression test here is merely parsing the model
 declaration. The verbose_name, in particular, did not always work.)
@@ -128,5 +134,11 @@ datetime.datetime(2000, 1, 1, 6, 1, 1)
 &gt;&gt;&gt; w
 &lt;Worker: Full-time&gt;
 
+# Models with broken unicode methods should still have a printable repr
+&gt;&gt;&gt; b = BrokenUnicodeMethod(name=&quot;Jerry&quot;)
+&gt;&gt;&gt; b.save()
+&gt;&gt;&gt; BrokenUnicodeMethod.objects.all()
+[&lt;BrokenUnicodeMethod: [Bad Unicode data]&gt;]
+
 &quot;&quot;&quot;
 }</diff>
      <filename>tests/regressiontests/model_regress/models.py</filename>
    </modified>
  </modified>
  <removed type="array"/>
  <parents type="array">
    <parent>
      <id>0389d5bf1c9e664c59ceb6b57b5b0c294ee1049c</id>
    </parent>
  </parents>
  <author>
    <name>kmtracey</name>
    <email>kmtracey@bcc190cf-cafb-0310-a4f2-bffc1f526a37</email>
  </author>
  <url>http://github.com/dcramer/django-compositepks/commit/9ecc2bd086f419a87039257a11aa26f69449340a</url>
  <id>9ecc2bd086f419a87039257a11aa26f69449340a</id>
  <committed-date>2008-11-16T10:58:43-08:00</committed-date>
  <authored-date>2008-11-16T10:58:43-08:00</authored-date>
  <message>Fixed #9608: Ensured a Model's default repr() is printable even if its __unicode__ method raises a Unicode error.


git-svn-id: http://code.djangoproject.com/svn/django/trunk@9475 bcc190cf-cafb-0310-a4f2-bffc1f526a37</message>
  <tree>5d51dead0070fa62e38c9fa211894338828e3c12</tree>
  <committer>
    <name>kmtracey</name>
    <email>kmtracey@bcc190cf-cafb-0310-a4f2-bffc1f526a37</email>
  </committer>
</commit>
