[issue9423] Error in urllib2.do_open(self, http_class, req)

Lyle Ross report at bugs.python.org
Fri Jul 30 01:09:08 CEST 2010

New submission from Lyle Ross <lyle.ross at us-cert.gov>:

W:\Production Apps\PyLib>python ProxyHTTPConnection.py

W:\Production Apps\PyLib>set path=C:\Python26;C:\Perl\bin\;C:\WINDOWS\system32;C:\WINDOWS;C:\WINDOWS\System32\
Wbem;;C:\Program Files\RSA Security\RSA Authentication Agent\Agenthost Autoreg Utility;C:\WINDOWS\system32\Win
dowsPowerShell\v1.0;C:\WINDOWS\system32\WindowsPowerShell\v1.0;C:\Program Files\TortoiseSVN\bin;W:\cmd;C:\Pyth
on26;C:\Program Files\Java\jdk1.6.0_20\bin;W:\Programs\nmake15;W:\Programs\GnuPG;C:\Cygwin\bin

W:\Production Apps\PyLib>python.exe -u ProxyHTTPConnection.py
Enter ProxyHTTPConnection :: __main__
  call opener = urllib2.build_opener( ConnectHTTPHandler( proxy = thunderchild.bronze.us-cert.gov ), ConnectHT
TPSHandler( proxy = thunderchild.bronze.us-cert.gov ) )
Enter ConnectHTTPHandler :: __init__
  call urllib2.HTTPHandler.__init__
Exit ConnectHTTPHandler :: __init__
Enter ConnectHTTPSHandler :: __init__
  call urllib2.HTTPSHandler.__init__
Exit ConnectHTTPSHandler :: __init__
  call urllib2.install_opener( opener )
  call req = urllib2.Request( url = https://portal.cymru.com/export/darknet_top10src_24h.txt )
  call req.set_proxy( thunderchild.bronze.us-cert.gov, https )
  f = call urllib2.urlopen( req )
Enter ConnectHTTPSHandler :: do_open
  call req.set_proxy( thunderchild.bronze.us-cert.gov, 'https' )
  rc = call urllib2.HTTPSHandler.do_open( self, ProxyHTTPSConnection, req )

Traceback (most recent call last):
  File "ProxyHTTPConnection.py", line 243, in <module>
    f      = urllib2.urlopen( req )
  File "C:\Python26\lib\urllib2.py", line 126, in urlopen
    return _opener.open(url, data, timeout)
  File "C:\Python26\lib\urllib2.py", line 391, in open
    response = self._open(req, data)
  File "C:\Python26\lib\urllib2.py", line 409, in _open
    '_open', req)
  File "C:\Python26\lib\urllib2.py", line 369, in _call_chain
    result = func(*args)
  File "C:\Python26\lib\urllib2.py", line 1169, in https_open
    return self.do_open(httplib.HTTPSConnection, req)
  File "ProxyHTTPConnection.py", line 204, in do_open
    rc = urllib2.HTTPSHandler.do_open( self, ProxyHTTPSConnection, req )
  File "C:\Python26\lib\urllib2.py", line 1107, in do_open
    h = http_class(host, timeout=req.timeout) # will parse host:port
TypeError: __init__() got an unexpected keyword argument 'timeout'
Exit ProxyHTTPConnection :: __main__
W:\Production Apps\PyLib>

NOTE: the proxy server used in this test is behind our firewall. You must change the proxy server if you attempt to replicate this test in your system.

components: Library (Lib)
files: ProxyHTTPConnection.py
messages: 112022
nosy: lyle.ross
priority: normal
severity: normal
status: open
title: Error in urllib2.do_open(self, http_class, req)
type: compile error
versions: Python 2.6
Added file: http://bugs.python.org/file18265/ProxyHTTPConnection.py

Python tracker <report at bugs.python.org>

More information about the Python-bugs-list mailing list