[pypy-commit] pypy stdlib-2.7.4: allow socket.getaddrinfo port to be a long, test (cpython issue8853)
bdkearns
noreply at buildbot.pypy.org
Wed Apr 10 00:02:18 CEST 2013
Author: Brian Kearns <bdkearns at gmail.com>
Branch: stdlib-2.7.4
Changeset: r63175:2a7832d3e68f
Date: 2013-04-09 17:54 -0400
http://bitbucket.org/pypy/pypy/changeset/2a7832d3e68f/
Log: allow socket.getaddrinfo port to be a long, test (cpython issue8853)
diff --git a/pypy/module/_socket/interp_func.py b/pypy/module/_socket/interp_func.py
--- a/pypy/module/_socket/interp_func.py
+++ b/pypy/module/_socket/interp_func.py
@@ -268,13 +268,14 @@
# port can be None, int or string
if space.is_w(w_port, space.w_None):
port = None
- elif space.isinstance_w(w_port, space.w_int):
+ elif space.isinstance_w(w_port, space.w_int) or space.isinstance_w(w_port, space.w_long):
port = str(space.int_w(w_port))
elif space.isinstance_w(w_port, space.w_str):
port = space.str_w(w_port)
else:
raise OperationError(space.w_TypeError,
- space.wrap("Int or String expected"))
+ space.wrap(
+ "getaddrinfo() argument 2 must be integer or string"))
try:
lst = rsocket.getaddrinfo(host, port, family, socktype,
proto, flags)
diff --git a/pypy/module/_socket/test/test_sock_app.py b/pypy/module/_socket/test/test_sock_app.py
--- a/pypy/module/_socket/test/test_sock_app.py
+++ b/pypy/module/_socket/test/test_sock_app.py
@@ -226,6 +226,9 @@
w_l = space.appexec([w_socket, space.wrap(host), space.wrap(port)],
"(_socket, host, port): return _socket.getaddrinfo(host, port)")
assert space.unwrap(w_l) == info
+ w_l = space.appexec([w_socket, space.wrap(host), space.wrap(port)],
+ "(_socket, host, port): return _socket.getaddrinfo(host, long(port))")
+ assert space.unwrap(w_l) == info
py.test.skip("Unicode conversion is too slow")
w_l = space.appexec([w_socket, space.wrap(unicode(host)), space.wrap(port)],
"(_socket, host, port): return _socket.getaddrinfo(host, port)")
More information about the pypy-commit
mailing list