New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Use getaddrinfo() in urllib2.py for IPv6 support #44672
Comments
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(). |
|
Hi, jjlee, skip: let me know your comments on this. One note we have to keep in mind is, testing on IPv6 address. test_urllib2 will PASS for the above. |
What I don't understand here is... if gethostbyname() lacks of IPv6 Right now gethostbyname() is implemented in C, which would be the |
Senthil, I don't think your gethost_addrinfo() function will work. On a v6- Also, why is the AI_CANONNAME flag set? The canonname field isn't used. |
Question: Why does FTPHandler.ftp_open() try to resolve the hostname()? |
Derek, This patch was along the lines that when IPv6 address is present, return I am not sure, if returning all the addresses would help and how would AI_CANONNAME flag, I don't accurately remember it now. But I had I am having different opinion on this issue now. First is, taking from Facundo's comment on having this functionality in Second is, the wrapper function and suitable way needs to be defined. I am sorry, I fail to understand the question on why ftp_open does |
My understanding is that the FileHandler checks if the file:// URL file:///foo.txt If that is the case, then doesn't FileHandler.names need to have all of I am a little confused by this though. It looks like For your other points, gethostbyname() in libc can only handle IPv4 Yes, FTPHandler creates an urllib.FTPWrapper object. That object calls |
You are right. Even I had observed this, but did not dispute it. Let
Thanks for the info. I shall look into both in revision of the path.
|
Note also bpo-5625 - any work for IPv6 should keep in mind that local |
@senthil should this be assigned to your good self? |
Bump. |
Note: these values reflect the state of the issue at the time it was migrated and might not reflect the current state.
Show more details
GitHub fields:
bugs.python.org fields:
The text was updated successfully, but these errors were encountered: