On Sun, 2007-11-04 at 10:54 +0000, omat wrote: > I change one thing at a time when debugging but after posting here, I > go on with experimenting. And when I respond to a request, like > posting the traceback, usually it is not the very exact instance that > I am running currently.
Well, there's a problem right there. If the code you are posting here is not the same code you are using to create the traceback, there are going to be (possibly important differences). I now have little confidence that what you're showing us matches the real problem. Construct the smallest example possible that shows the issue so that people can repeat it. That's the usual procedure. You said your data had type unicode, but it looks like (below) it's actually a bytestring, for example. The differences are very important in cases like this. You might want to try subversion trunk, since I added extra debugging to smart_unicode and force_unicode so that they show the data you pass in and it's type as part of the output. Maybe that will give you more information. > I change it to be consistent with the on going > discussion, but sometimes there are some portions that are not > matched. But they have the same nature of problem. > > In our case, the message and the subject have the same problem and > generated almost identical tracebacks, when instance.name contains non- > ascii chars. > > And here is my Tag model: > > class Tag(models.Model): > name = models.CharField(max_length=50, > db_index=True, > validator_list=[isTag]) > slug = models.SlugField(editable = False, > unique = True) > ignore = models.BooleanField(default=False) > synonym_for = models.ForeignKey('self', blank=True, null=True) > > objects = TagManager() > > def save(self): > self.slug = slugify(self.name) > super(Tag, self).save() > > def __unicode__(self): > name = self.name > if self.ignore: > name = u'%s (x)' % (name) > if self.synonym_for: > name = u'%s => %s' % (name, self.synonym_for.name) > return name > I don't see how you're getting this problem with self.name being a Unicode object, so let's confirm that. In fact, it looks a lot like self.name would be a bytestring -- that would certainly explain the UnicodeDecodeError, because you cannot substitute non-ASCII bytestrings into a u'%s' format string. If 'name' is a bytestring (or if self.synonym_for.name is a bytestring), you'll need to manually call force_unicode() on them before trying to substitute them into the u'%s => %s' bit. Anyway, good luck with your problem, but until the code you are showing can be used to repeat the problem and isn't a variation that you have changed without knowing what is significant, I cannot help any further. Malcolm -- If at first you don't succeed, destroy all evidence that you tried. http://www.pointy-stick.com/blog/ --~--~---------~--~----~------------~-------~--~----~ You received this message because you are subscribed to the Google Groups "Django users" group. To post to this group, send email to django-users@googlegroups.com To unsubscribe from this group, send email to [EMAIL PROTECTED] For more options, visit this group at http://groups.google.com/group/django-users?hl=en -~----------~----~----~----~------~----~------~--~---