Sorry, went a bit too quickly -- here is the sample code that I meant to use:
import os, urllib2
os.environ['http_proxy'] = "http://someuser:a/[email protected]:1234"
f = urllib2.urlopen('http://www.python.org')
data = f.read()
print data
And the stack trace that I receive:
Traceback (most recent call last):
File "test.py", line 3, in <module>
f = urllib2.urlopen('http://www.python.org')
File "/usr/lib64/python2.7/urllib2.py", line 154, in urlopen
return opener.open(url, data, timeout)
File "/usr/lib64/python2.7/urllib2.py", line 431, in open
response = self._open(req, data)
File "/usr/lib64/python2.7/urllib2.py", line 449, in _open
'_open', req)
File "/usr/lib64/python2.7/urllib2.py", line 409, in _call_chain
result = func(*args)
File "/usr/lib64/python2.7/urllib2.py", line 1227, in http_open
return self.do_open(httplib.HTTPConnection, req)
File "/usr/lib64/python2.7/urllib2.py", line 1166, in do_open
h = http_class(host, timeout=req.timeout, **http_conn_args)
File "/usr/lib64/python2.7/httplib.py", line 712, in __init__
(self.host, self.port) = self._get_hostport(host, port)
File "/usr/lib64/python2.7/httplib.py", line 754, in _get_hostport
raise InvalidURL("nonnumeric port: '%s'" % host[i+1:])
httplib.InvalidURL: nonnumeric port: 'a'
It actually looks the same -- so I suppose this issue affects both urllib and urllib2. |