Problem when applying Patch from issue1424152 to get https over authenticating proxies working with urllib2 in Python 2.5

tvashtar tvashtar at
Mon Jul 20 13:58:53 EDT 2009

On Jul 20, 4:42 pm, Nike <nike... at> wrote:
> hi!
>  It's looks like a ssl error . Under the following step to help u :
>   1. takes a simple code to confirm your pupose without ssl protocol.
>   2. to confirm python version and extended libs work well
>   3. to confirm ssl work well.
> goog luck!
> nikekoo

I've reduced my code to the following:

import urllib2

p = "https://user:pass@myproxy:port"
proxy_handler = urllib2.ProxyHandler({"https": p})
request = urllib2.Request( "")
response = urllib2.urlopen(request)

and it is now failing with:

Traceback (most recent call last):
  File "D:\p4\depot\Development\HEAD\Build\ReleaseSystem\DownloadSystem
\", line 12, in <module>
    response = urllib2.urlopen(request)
  File "C:\Python25\lib\", line 121, in urlopen
    return, data)
  File "C:\Python25\lib\", line 379, in open
    response = self._open(req, data)
  File "C:\Python25\lib\", line 397, in _open
    '_open', req)
  File "C:\Python25\lib\", line 358, in _call_chain
    result = func(*args)
  File "C:\Python25\lib\", line 1115, in https_open
    return self.do_open(httplib.HTTPSConnection, req)
  File "C:\Python25\lib\", line 1082, in do_open
    raise URLError(err)
urllib2.URLError: <urlopen error Tunnel connection failed: 407 Proxy
Authentication Required>

I thought the proxy_handler should take care of the authentication?

Thanks for your help

More information about the Python-list mailing list