Wiadomość napisana w dniu 2008-09-11, o godz. 14:16, przez ekellner:
> Coding cookie has nothing to do with bytestring literals decoding, > it's only for unicode literals. If you try to coerce bytestring with > unicode, decoding will be done using default system encoding, if > encoding is not specified explicitly. > > Indeed, that's why changing the python default encoding (no matter > how 'dangerous' this is supposed to be) is the only technique that > worked. > > Please correct me if I am wrong then, but if the coding is supposed > to be specified explicitly, it seems like django is failing to do > that in its handling of __str__. If my model is returning utf-8 > data in its __unicode__ function, that shouldn't cause any > problems. That's the point of __unicode__. Text in utf-8 is not unicode, this is bytestring (what we had in 0.96 in __str__). From __unicode__ you have to return unicode ubjects, not utf-8 encoded bytestrings. Fredrik Lundh has some good introductory material on handling strings vs. unicode: <http://effbot.org/zone/unicode-objects.htm> > Just do not use bytestrings to represent textual data. Soon (with > Python 3) it will be considered bad habit. > > This means changing every "string" into u"string", right? This is > where I thought that the coding: cookie was supposed to fix things; > you tell python that your bytestring is in utf-8 so you don't have > to label every single string in your code individually. Forcing > each expression into a specific type seems very un-pythonic. Well, I am not BDFL, I'm not in a power to change anything in Python internals (but if you ask me, I prefer clean separation of "texts" from "bytes" Java has from the beginning). In Python 3 'string' will contain unicode objects, b'string' will contain bytes (for convenience, I think). -- We read Knuth so you don't have to. - Tim Peters Jarek Zgoda, R&D, Redefine [EMAIL PROTECTED] --~--~---------~--~----~------------~-------~--~----~ 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 -~----------~----~----~----~------~----~------~--~---