Flavio schrieb: > something like this, for instance: > http://.wikipedia.org/wiki/Copper%28II%29_hydroxide > > but even url with any non-ascii characters such as this > > http://.wikipedia.org/wiki/Ammonia > > also fail when passed to urlopen : > File "/usr/lib/python2.4/encodings/idna.py", line 72, in ToASCII > raise UnicodeError, "label too long" > UnicodeError: label too long > > very strange, because I tried other unicode urls from the python > console like this
It's the host name that starts with a dot that makes it fails: py> u".wikipedia.org".encode("idna") Traceback (most recent call last): File "<stdin>", line 1, in ? File "encodings/idna.py", line 163, in encode File "encodings/idna.py", line 72, in ToASCII UnicodeError: label too long py> u"wikipedia.org".encode("idna") 'wikipedia.org' The exception is certainly misleading; I'll have to find out whether there is a bug beyond that (i.e. whether host names with empty labels should be accepted). Regards, martin -- http://mail.python.org/mailman/listinfo/python-list