Author: mattip <[email protected]>
Branch: issue1430
Changeset: r71154:2e3fc0780b66
Date: 2014-05-02 00:14 +0300
http://bitbucket.org/pypy/pypy/changeset/2e3fc0780b66/
Log: make API backward-compatible
diff --git a/rpython/rlib/rsocket.py b/rpython/rlib/rsocket.py
--- a/rpython/rlib/rsocket.py
+++ b/rpython/rlib/rsocket.py
@@ -1124,14 +1124,22 @@
paddr = h_addr_list[i]
return (rffi.charp2str(hostent.c_h_name), aliases, address_list)
-def gethostbyname_ex(name, lock):
+class DummyLock(object):
+ def __enter__(self):
+ pass
+
+ def __exit__(self, *args):
+ pass
+
+
+def gethostbyname_ex(name, lock=DummyLock()):
# XXX use gethostbyname_r() if available instead of locks
addr = gethostbyname(name)
with lock:
hostent = _c.gethostbyname(name)
return gethost_common(name, hostent, addr)
-def gethostbyaddr(ip, lock):
+def gethostbyaddr(ip, lock=DummyLock()):
# XXX use gethostbyaddr_r() if available, instead of locks
addr = makeipaddr(ip)
assert isinstance(addr, IPAddress)
diff --git a/rpython/rlib/test/test_rsocket.py
b/rpython/rlib/test/test_rsocket.py
--- a/rpython/rlib/test/test_rsocket.py
+++ b/rpython/rlib/test/test_rsocket.py
@@ -3,13 +3,6 @@
from rpython.rlib.rsocket import *
import socket as cpy_socket
-class DummyLock(object):
- def __enter__(self):
- pass
-
- def __exit__(self, *args):
- pass
-
def setup_module(mod):
rsocket_startup()
@@ -55,7 +48,7 @@
def test_gethostbyname_ex():
for host in ["localhost", "127.0.0.1"]:
- name, aliases, address_list = gethostbyname_ex(host, DummyLock())
+ name, aliases, address_list = gethostbyname_ex(host)
allnames = [name] + aliases
for n in allnames:
assert isinstance(n, str)
@@ -120,7 +113,7 @@
with py.test.raises(ipv6):
gethostbyaddr(host)
continue
- name, aliases, address_list = gethostbyaddr(host, DummyLock())
+ name, aliases, address_list = gethostbyaddr(host)
allnames = [name] + aliases
for n in allnames:
assert isinstance(n, str)
_______________________________________________
pypy-commit mailing list
[email protected]
https://mail.python.org/mailman/listinfo/pypy-commit