Author: Brian Kearns <[email protected]>
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)")
_______________________________________________
pypy-commit mailing list
[email protected]
http://mail.python.org/mailman/listinfo/pypy-commit

Reply via email to