]> granicus.if.org Git - python/commit
Repair redirect handling and raise URLError on host-not-found.
authorJeremy Hylton <jeremy@alum.mit.edu>
Sun, 4 May 2003 23:44:49 +0000 (23:44 +0000)
committerJeremy Hylton <jeremy@alum.mit.edu>
Sun, 4 May 2003 23:44:49 +0000 (23:44 +0000)
commit828023b6b5d4d84a3fc01e9907142662a33d45a6
tree1f7797a585fb80a1e618fd115d14e827190586fa
parent258dfebfb4286afe176cce1d6f6245d53112fc1a
Repair redirect handling and raise URLError on host-not-found.

The latest changes to the redirect handler couldn't possibly have been
tested, because they did not compute a newurl and failed with a
NameError.  The __name__ == "__main__": block has a test for
redirects.

Also, fix SF bug 723831.  A urlopen() that failed because the host was
not found raised a socket.gaierror unlike earlier versions of
urllib2.  The problem is that httplib actually establishes the
connection at a different point starting with Python 2.2.  Move the
try/except to endheaders(), which is where the connection gets
established.
Lib/urllib2.py