[ python-Patches-1675455 ] Use getaddrinfo() in urllib2.py for IPv6 support

"SourceForge.net" <[email protected]> Wed, 11 Jul 2007 16:57:21 -0700
Newsgroups gmane.comp.python.patches
Message-ID <[email protected]>
Patches item #1675455, was opened at 2007-03-07 05:19
Message generated for change (Comment added) made by jjlee
You can respond by visiting: 
https://sourceforge.net/tracker/?func=detail&atid=305470&aid=1675455&group_id=5470

Please note that this message will contain a full copy of the comment thread,
including the initial issue submission, for this request,
not just the latest update.
Category: Library (Lib)
Group: None
Status: Open
Resolution: None
Priority: 5
Private: No
Submitted By: David Cantrell (dcantrell-rh)
Assigned to: Nobody/Anonymous (nobody)
Summary: Use getaddrinfo() in urllib2.py for IPv6 support

Initial Comment:
A number of base Python modules use gethostbyname() when they should be using getaddrinfo().  The big limitation hit when using gethostbyname() is the lack of IPv6 support.

This first patch is for urllib2.py.  It replaces all uses of gethostbyname() with getaddrinfo() instead.  getaddrinfo() returns a 5-tuple, so additional code needs to wrap a getaddrinfo() call when replacing gethostbyname() calls.  Still should be pretty simple to read.

I'd like to see this patch added to the next stable release of Python, if at all possible.  I am working up patches for the other modules I see in the Lib/ subdirectory that could use getaddrinfo() instead of gethostbyname().

----------------------------------------------------------------------

Comment By: John J Lee (jjlee)
Date: 2007-07-12 00:57

Message:
Logged In: YES 
user_id=261020
Originator: NO

* Where are the tests?  A functional test, perhaps in test_urllib2net.py,
for IPv6 support in urllib2 would be especially welcome, I think.
* Why does .check_host() not begin with an underscore?
* "check_host" is a poor name.  How about "_is_localhost"?
* locals is a built-in function, hence usually considered good style not
to use it as a name.
* Is is necessary to call make_host_tuple(searchlist) twice?
* The patch appears to fix several bugs at once (e.g. adding a try: /
except: suite around a large part of an existing method to catch
socket.error).


----------------------------------------------------------------------

You can respond by visiting: 
https://sourceforge.net/tracker/?func=detail&atid=305470&aid=1675455&group_id=5470