On Mon, Jul 27, 2009 at 3:26 PM, Shivaraj<shivraj...@gmail.com> wrote: > > Let me repeat the original question. > If I put a nonASCII character to urlopen / urlencode and try to open > an url in python prompt it works fine. > So it's not issue with python(2.6+) as of now. > > Now I call the same functions from Django and it reports error.
And let me repeat my original answer. You seem to be of the opinion that Django is - or is capable of - doing something here. It isn't. Django is just a library. It doesn't change the operation of the functions in the standard library. If you're seeing errors, you will see them consistently regardless of whether they are at the Python prompt or being invoked from within a Django view, barring differences in file encoding, etc - that is, the conditions that will alter the operation of the standard library. > I will give you a simple scenario. Try unicode('район','utf-8') from > any view function and it will throw a TypeError stating decoding is > not permitted or so. It doesn't do that on my machine. I do get a Syntax error if my file doesn't have a PEP-263 compliant coding string (# -*- coding: utf-8 -*-), since 'район' isn't a legal ASCII string. If the coding string is present, the I don't get any error. I do get a TypeError if I try to call unicode(u'район','utf-8') (i.e., inputing an explicitly unicode string), - but that's understandable, since I'm asking for a UTF-8 decode of a string that is already Unicode. This also happens regardless of whether I'm at a Python prompt or in a Django view - which is understandable, since it's a fundamentally incorrect way to invoke unicode(). I don't know exactly what you're hitting here, but it's a lot more subtle than "Django did it". Yours, Russ Magee %-) --~--~---------~--~----~------------~-------~--~----~ 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 django-users+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/django-users?hl=en -~----------~----~----~----~------~----~------~--~---