urllib.urlopen doesn't accept Unicode strings.
Martin von Loewis
loewis at informatik.hu-berlin.de
Wed Mar 21 17:31:22 EST 2001
"Syver Enstad" <syver at NOSPAMcyberwatcher.com> writes:
> The offending line is at 241 in urllib.py (python 2.0)
>
> def open_http(self, url, data=None):
> """Use HTTP protocol."""
> import httplib
> user_passwd = None
> # next line patched, original line was: if type(url) is type(""):
> if type(url) is type("") or type(url) is type(u""):
> host, selector = splithost(url)
> if host:
>
> Or maybe this has been fixed in Python 2.1?
No, it hasn't. Please submit a patch to
sourceforge.net/projects/python. I recommend you start from the
current code base, though - using types.UnicodeType is much better
than type(u""). I normally write this as
if type(url) in [types.StringType, types.UnicodeType]
Regards,
Martin
More information about the Python-list
mailing list