-
-
Notifications
You must be signed in to change notification settings - Fork 30.9k
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
nntplib is not IPv6-capable #46005
Comments
nntplib hardcodes AF_INET for the socket address family. This prevents |
This patch doesn't appear to work for python2.5.1 -> Python 2.5.1 (r251:54863, Jun 15 2008, 18:24:51)
[GCC 4.3.0 20080428 (Red Hat 4.3.0-8)] on linux2
Type "help", "copyright", "credits" or "license" for more information.
>>> from nntplib import NNTP
>>> conn = NNTP('newszilla6.xs4all.nl')
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
File "/usr/lib/python2.5/nntplib.py", line 114, in __init__
self.sock = socket.create_connection((host, port))
AttributeError: 'module' object has no attribute 'create_connection' (at least for me it doesn't work... I'd be happy to try something else, or debug in other ways it that'd |
Yes. The patch is against 2.6. It uses the socket.create_connection() If you really want to apply it to 2.5, it's trivial to adapt the patch. msg = "getaddrinfo returns an empty list"
for res in getaddrinfo(host, port, 0, SOCK_STREAM):
af, socktype, proto, canonname, sa = res
sock = None
try:
sock = socket(af, socktype, proto)
if timeout is not _GLOBAL_DEFAULT_TIMEOUT:
sock.settimeout(timeout)
sock.connect(sa)
self.sock = sock
raise error, msg |
oh crap :( I saw the 2.6 AFTER I posted the message :( sorry. grr, have Thanks. |
oy, and I'm not reading emails properly. I'll try the fix you propose |
a possible fix for 2.5 is: morrowc@tweezer:/tmp$ diff -U3 nntplib.py.orig nntplib.py
--- nntplib.py.orig 2008-12-30 01:06:14.000000000 -0500
+++ nntplib.py 2008-12-30 01:07:33.000000000 -0500
@@ -109,8 +109,19 @@
"""
self.host = host
self.port = port
- self.sock = socket.socket(socket.AF_INET, socket.SOCK_STREAM)
- self.sock.connect((self.host, self.port))
+ msg = "getaddrinfo returns an empty list"
+ for res in socket.getaddrinfo(self.host, self.port, 0,
socket.SOCK_STREAM):
+ af, socktype, proto, canonname, sa = res
+ sock = None
+ try:
+ self.sock = socket.socket(af, socktype, proto)
+ self.sock.connect(sa)
+
+ except error, msg:
+ if self.sock is not None:
+ self.sock.close()
+ raise NNTPError, msg
+
self.file = self.sock.makefile('rb')
self.debugging = 0
self.welcome = self.getresp() I'll open a bug against 2.5 now with this. |
I like nntplib_ipv6.patch: it's a generic solution (may support |
About Python 2.5: this branch doesn't accept bugfix anymore, only |
Are we sure that the 2.6 fix (in the patch) will make it into 2.6? (and |
I was going to suggest writing a test but I see that nntplib hasn't got |
Any chance of this being applied soon? It's been sitting in the |
@dmorr: It would be faster if nntplib has some tests :-/ |
I'm confused by that. In order to apply a 3 line patch (which replaces one standard library If we're willing to accept that nttplib works reasonably well now, why |
This is a little silly and painful... it's utterly broken to hardcode It seems really lame to not be able to support normal internet protocols |
Assuming the patch does work, +1 for applying it. |
Your patch is committed in r72640. Thanks! |
Thanks. Is there any chance of getting bug 1655 fixed as well? imaplib has the |
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: