[Python-bugs-list] [ python-Bugs-465502 ] urllib2: urlopen unicode problem (original) (raw)
noreply@sourceforge.net noreply@sourceforge.net
Tue, 09 Oct 2001 09:19:32 -0700
- Previous message: [Python-bugs-list] [ python-Bugs-467145 ] Python 2.2a4 build problem on HPUX 11.0
- Next message: [Python-bugs-list] [ python-Bugs-467145 ] Python 2.2a4 build problem on HPUX 11.0
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]
Bugs item #465502, was opened at 2001-09-26 20:58 You can respond by visiting: http://sourceforge.net/tracker/?func=detail&atid=105470&aid=465502&group_id=5470
Category: Python Library Group: Python 2.1.1
Status: Closed Resolution: Fixed Priority: 5 Submitted By: John Quigley (jmquigs) Assigned to: Jeremy Hylton (jhylton) Summary: urllib2: urlopen unicode problem
Initial Comment: It seems like urlopen doesn't like unicode strings for urls:
Python 2.1.1 (#1, Jul 23 2001, 22:08:25) [GCC 2.96 20000731 (Red Hat Linux 7.1 2.96-81)] on linux2 Type "copyright", "credits" or "license" for more information.
import urllib2 url = u"http://www.yahoo.com" urllib2.urlopen(url) Traceback (most recent call last): File "", line 1, in ? File "/home/john/python-install/lib/python2.1/urllib2.py", line 135, in urlopen return _opener.open(url, data) File "/home/john/python-install/lib/python2.1/urllib2.py", line 310, in open assert isinstance(req, Request) # really only care about interface AssertionError
One fix which seems to work is to add:
or type(fullurl) == types.UnicodeType
to the if on line 303 (Matrix!!!) of urllib2.py.
Comment By: Jeremy Hylton (jhylton) Date: 2001-10-09 09:19
Message: Logged In: YES user_id=31392
Fixed in rev. 1.22.
Comment By: Martin v. L�wis (loewis) Date: 2001-09-28 00:28
Message: Logged In: YES user_id=21627
For cases like this, I'd propose to use types.StringTypes until there is a common base type for both. This allows the code to continue to work even if Unicode is configured out of the compiler; the idiom then is
type(fullurl) in types.StringTypes
Comment By: Guido van Rossum (gvanrossum) Date: 2001-09-27 11:08
Message: Logged In: YES user_id=6380
He's right. Assigned to Jeremy. (This is trivial, but I'd like you to look it over.)
(Note to Jeremy: I'm not quite comfortable with all the isinstance() checks in your code. I'm afraid that some of these are already broken in 2.2, e.g. is_callable(). It would be better to test for specific attributes to make the distinctions or tests you need to make.)
You can respond by visiting: http://sourceforge.net/tracker/?func=detail&atid=105470&aid=465502&group_id=5470
- Previous message: [Python-bugs-list] [ python-Bugs-467145 ] Python 2.2a4 build problem on HPUX 11.0
- Next message: [Python-bugs-list] [ python-Bugs-467145 ] Python 2.2a4 build problem on HPUX 11.0
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]