This issue tracker has been migrated to GitHub, and is currently read-only.
For more information, see the GitHub FAQs in the Python's Developer Guide.

classification
Title: urllib2.urlopen fails on redirects?
Type: Stage:
Components: Library (Lib) Versions:
process
Status: closed Resolution: fixed
Dependencies: Superseder:
Assigned To: jhylton Nosy List: jeffcjohnson, jhylton
Priority: normal Keywords:

Created on 2000-10-11 19:04 by jeffcjohnson, last changed 2022-04-10 16:02 by admin. This issue is now closed.

Messages (2)
msg2004 - (view) Author: Jeff C Johnson (jeffcjohnson) Date: 2000-10-11 19:04
The following code produces an AttributeError exception un urllib2.  The equivalent code run from urllib works ok.  This was tested on Windows 2000, Python 2.0 Release Candidate 1.

### TEST CODE ########################
def testUrlRedirect(url):
	print "urllib.urlopen - ",
	u = urllib.urlopen(url)
	print "SUCCESS"

	print "urllib2.urlopen - ",
	u = urllib2.urlopen(url)
	print "SUCCESS"
testUrlRedirect('http://www.realestatemarketing.com')


### OUTPUT ##########################
urllib.urlopen -  SUCCESS
urllib2.urlopen -
Traceback (most recent call last):
  File "C:\dev_share\ffs\bin\brokers.py", line 38, in ?
    testUrlRedirect('http://www.realestatemarketing.com')
  File "C:\dev_share\ffs\bin\brokers.py", line 34, in testUrlRedirect
    u = urllib2.urlopen(url)
  File "c:\python20\lib\urllib2.py", line 137, in urlopen
    return _opener.open(url, data)
  File "c:\python20\lib\urllib2.py", line 321, in open
    '_open', req)
  File "c:\python20\lib\urllib2.py", line 300, in _call_chain
    result = apply(func, args)
  File "c:\python20\lib\urllib2.py", line 757, in http_open
    if h.sock:
AttributeError: 'HTTP' instance has no attribute 'sock'
msg2005 - (view) Author: Jeremy Hylton (jhylton) (Python triager) Date: 2000-10-12 19:54
Fixed in revision 1.6 of urllib2
History
Date User Action Args
2022-04-10 16:02:30adminsetgithub: 33333
2000-10-11 19:04:06jeffcjohnsoncreate