[Python-bugs-list] [ python-Bugs-503031 ] urllib.py: open_http() host problem
noreply@sourceforge.net
noreply@sourceforge.net
Sun, 13 Jan 2002 13:33:36 -0800
Bugs item #503031, was opened at 2002-01-13 10:09
You can respond by visiting:
http://sourceforge.net/tracker/?func=detail&atid=105470&aid=503031&group_id=5470
Category: Python Library
Group: Python 2.2
Status: Open
Resolution: None
Priority: 5
Submitted By: Jason Cowley (sachmoz)
Assigned to: Nobody/Anonymous (nobody)
Summary: urllib.py: open_http() host problem
Initial Comment:
While trying to use the httplib.py urlopen() function,
as follows:
doc = urlopen("http://www.python.org").read()
print doc
I was receiving the following trace:
Traceback (most recent call last):
File "C:/Documents and
Settings/Administrator/Desktop/jason/grabpage.py",
line 3, in ?
doc = urlopen("http://www.python.org").read()
File "C:\Python22\lib\urllib.py", line 73, in urlopen
return _urlopener.open(url)
File "C:\Python22\lib\urllib.py", line 178, in open
return getattr(self, name)(url)
File "C:\Python22\lib\urllib.py", line 283, in
open_http
h = httplib.HTTP(host)
File "C:\Python22\lib\httplib.py", line 688, in
__init__
self._setup(self._connection_class(host, port))
File "C:\Python22\lib\httplib.py", line 343, in
__init__
self._set_hostport(host, port)
File "C:\Python22\lib\httplib.py", line 349, in
_set_hostport
port = int(host[i+1:])
ValueError: invalid literal for int():
I managed to track the problem down to the function
open_http() in urllib.py. The value of the 'host'
variable contained the string 'http:' rather
than 'www.python.org', when a call is made as follows:
httplib.HTTP(host)
Line 272 of urllib.py should be setting the
variable 'host' to the value of 'realhost' but the
statement is never executed. The function 'proxy_bypas
()' doesn't appear to do anything but return 0.
I fixed it for my own purposes by adding a statement:
host = realhost
----------------------------------------------------------------------
>Comment By: Guido van Rossum (gvanrossum)
Date: 2002-01-13 13:33
Message:
Logged In: YES
user_id=6380
I cannot reproduce this.
What are your proxy settings?
----------------------------------------------------------------------
You can respond by visiting:
http://sourceforge.net/tracker/?func=detail&atid=105470&aid=503031&group_id=5470