Message234809
On Python 2.7.9, if I set an https_proxy environment variable, where the password contains a '/' character, urllib2 fails. Given this test code:
import os, urllib
os.environ['http_proxy'] = "http://someuser:a/b@10.11.12.13:1234"
f = urllib.urlopen('http://www.python.org')
data = f.read()
print data
I expect this error message (because my sample proxy is totally bogus):
[areitz@SOMEHOST ~]$ python2.7 test.py
Traceback (most recent call last):
File "test.py", line 3, in <module>
f = urllib.urlopen('http://www.python.org')
File "/usr/lib64/python2.7/urllib.py", line 87, in urlopen
return opener.open(url)
File "/usr/lib64/python2.7/urllib.py", line 213, in open
return getattr(self, name)(url)
File "/usr/lib64/python2.7/urllib.py", line 350, in open_http
h.endheaders(data)
File "/usr/lib64/python2.7/httplib.py", line 997, in endheaders
self._send_output(message_body)
File "/usr/lib64/python2.7/httplib.py", line 850, in _send_output
self.send(msg)
File "/usr/lib64/python2.7/httplib.py", line 812, in send
self.connect()
File "/usr/lib64/python2.7/httplib.py", line 793, in connect
self.timeout, self.source_address)
File "/usr/lib64/python2.7/socket.py", line 571, in create_connection
raise err
IOError: [Errno socket error] [Errno 101] Network is unreachable
Instead, I receive this error:
[areitz@SOMEHOST ~]$ python2.7 test.py
Traceback (most recent call last):
File "test.py", line 3, in <module>
f = urllib.urlopen('http://www.python.org')
File "/usr/lib64/python2.7/urllib.py", line 87, in urlopen
return opener.open(url)
File "/usr/lib64/python2.7/urllib.py", line 213, in open
return getattr(self, name)(url)
File "/usr/lib64/python2.7/urllib.py", line 339, in open_http
h = httplib.HTTP(host)
File "/usr/lib64/python2.7/httplib.py", line 1107, in __init__
self._setup(self._connection_class(host, port, strict))
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'
Note that from the error, it seems as if urllib2 is incorrectly parsing the password from the proxy URL. When trying this with curl 7.19.7, I see the proper behavior (the correct password is parsed from the proxy URL). |
|
Date |
User |
Action |
Args |
2015-01-27 07:03:55 | Andy.Reitz | set | recipients:
+ Andy.Reitz |
2015-01-27 07:03:55 | Andy.Reitz | set | messageid: <1422342235.17.0.905041944591.issue23328@psf.upfronthosting.co.za> |
2015-01-27 07:03:54 | Andy.Reitz | link | issue23328 messages |
2015-01-27 07:03:52 | Andy.Reitz | create | |
|