[pypy-svn] r42109 - in pypy/dist/pypy/rlib: . test
afa at codespeak.net
afa at codespeak.net
Tue Apr 17 01:19:54 CEST 2007
Author: afa
Date: Tue Apr 17 01:19:54 2007
New Revision: 42109
Modified:
pypy/dist/pypy/rlib/getaddrinfo.py
pypy/dist/pypy/rlib/test/test_rsocket.py
Log:
CPython2.3 on Windows did perform a reverse DNS lookup in getaddrinfo.
Implement 2.4 behaviour, which is consistent with Unix platforms.
Modified: pypy/dist/pypy/rlib/getaddrinfo.py
==============================================================================
--- pypy/dist/pypy/rlib/getaddrinfo.py (original)
+++ pypy/dist/pypy/rlib/getaddrinfo.py Tue Apr 17 01:19:54 2007
@@ -164,13 +164,17 @@
sizeof(_c.sockaddr_in), address_to_fill)
return [(_c.AF_INET, socktype, protocol, None, addr)]
else:
- # XXX getaddrinfo() is a name->address translation function,
- # and it looks strange that we do addr->name translation here.
sin = _c.sockaddr_in(sin_family=_c.AF_INET, sin_port=port)
sin.sin_addr.s_addr = packedaddr
- canonname = get_name(hostname, sin.sin_addr, sizeof(_c.in_addr))
+ # getaddrinfo() is a name->address translation function,
+ # and it looks strange that we do addr->name translation here.
+ # This is what python2.3 did on Windows:
+ # if sys.version < (2, 4):
+ # canonname = get_name(hostname, sin.sin_addr,
+ # sizeof(_c.in_addr))
+ canonname = hostname
addr = make_address(cast(pointer(sin), POINTER(_c.sockaddr)),
sizeof(_c.sockaddr_in), address_to_fill)
Modified: pypy/dist/pypy/rlib/test/test_rsocket.py
==============================================================================
--- pypy/dist/pypy/rlib/test/test_rsocket.py (original)
+++ pypy/dist/pypy/rlib/test/test_rsocket.py Tue Apr 17 01:19:54 2007
@@ -191,21 +191,15 @@
found = True
assert found, lst
-def test_getaddrinfo_reverse_snake():
+def test_getaddrinfo_no_reverse_lookup():
+ # It seems that getaddrinfo never runs a reverse lookup on Linux.
+ # Python2.3 on Windows returns the hostname.
lst = getaddrinfo('134.99.112.214', None, flags=AI_CANONNAME)
assert isinstance(lst, list)
found = False
for family, socktype, protocol, canonname, addr in lst:
- if canonname == 'snake.cs.uni-duesseldorf.de':
- found = True
- assert found, lst
-
-def test_getaddrinfo_reverse_lookup_fail():
- lst = getaddrinfo('1.2.3.4', None, flags=AI_CANONNAME)
- assert isinstance(lst, list)
- found = False
- for family, socktype, protocol, canonname, addr in lst:
- if canonname == '1.2.3.4':
+ assert canonname != 'snake.cs.uni-duesseldorf.de'
+ if addr.get_host() == '134.99.112.214':
found = True
assert found, lst
More information about the Pypy-commit
mailing list