[pypy-commit] pypy missing-ndarray-attributes: change socket type to socket s_type, 'type' should never be used as variable name
mattip
noreply at buildbot.pypy.org
Mon Feb 4 21:52:46 CET 2013
Author: mattip <matti.picus at gmail.com>
Branch: missing-ndarray-attributes
Changeset: r60872:81d15ae6c6bc
Date: 2013-02-04 20:50 +0200
http://bitbucket.org/pypy/pypy/changeset/81d15ae6c6bc/
Log: change socket type to socket s_type, 'type' should never be used as
variable name
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
@@ -126,24 +126,24 @@
raise converted_error(space, e)
return space.newtuple([space.wrap(host), space.wrap(servport)])
- at unwrap_spec(fd=int, family=int, type=int, proto=int)
-def fromfd(space, fd, family, type, proto=0):
- """fromfd(fd, family, type[, proto]) -> socket object
+ at unwrap_spec(fd=int, family=int, s_type=int, proto=int)
+def fromfd(space, fd, family, s_type, proto=0):
+ """fromfd(fd, family, s_type[, proto]) -> socket object
Create a socket object from the given file descriptor.
The remaining arguments are the same as for socket().
"""
try:
- sock = rsocket.fromfd(fd, family, type, proto, W_RSocket)
+ sock = rsocket.fromfd(fd, family, s_type, proto, W_RSocket)
except SocketError, e:
raise converted_error(space, e)
return space.wrap(sock)
- at unwrap_spec(family=int, type=int, proto=int)
+ at unwrap_spec(family=int, s_type=int, proto=int)
def socketpair(space, family=rsocket.socketpair_default_family,
- type =rsocket.SOCK_STREAM,
+ s_type =rsocket.SOCK_STREAM,
proto =0):
- """socketpair([family[, type[, proto]]]) -> (socket object, socket object)
+ """socketpair([family[, s_type[, proto]]]) -> (socket object, socket object)
Create a pair of socket objects from the sockets returned by the platform
socketpair() function.
@@ -151,7 +151,7 @@
AF_UNIX if defined on the platform; otherwise, the default is AF_INET.
"""
try:
- sock1, sock2 = rsocket.socketpair(family, type, proto, W_RSocket)
+ sock1, sock2 = rsocket.socketpair(family, s_type, proto, W_RSocket)
except SocketError, e:
raise converted_error(space, e)
return space.newtuple([space.wrap(sock1), space.wrap(sock2)])
diff --git a/pypy/module/_socket/interp_socket.py b/pypy/module/_socket/interp_socket.py
--- a/pypy/module/_socket/interp_socket.py
+++ b/pypy/module/_socket/interp_socket.py
@@ -146,7 +146,7 @@
try:
fd, addr = self.accept()
sock = rsocket.make_socket(
- fd, self.family, self.type, self.proto, W_RSocket)
+ fd, self.family, self.s_type, self.proto, W_RSocket)
return space.newtuple([space.wrap(sock),
addr_as_object(addr, sock.fd, space)])
except SocketError, e:
@@ -540,16 +540,16 @@
return os.fdopen(newfd, mode, buffersize)
''', filename =__file__).interphook('makefile')
- at unwrap_spec(family=int, type=int, proto=int)
+ at unwrap_spec(family=int, s_type=int, proto=int)
def newsocket(space, w_subtype, family=AF_INET,
- type=SOCK_STREAM, proto=0):
- # XXX If we want to support subclassing the socket type we will need
+ s_type=SOCK_STREAM, proto=0):
+ # XXX If we want to support subclassing the socket s_type we will need
# something along these lines. But allocate_instance is only defined
# on the standard object space, so this is not really correct.
#sock = space.allocate_instance(W_RSocket, w_subtype)
- #Socket.__init__(sock, space, fd, family, type, proto)
+ #Socket.__init__(sock, space, fd, family, s_type, proto)
try:
- sock = W_RSocket(family, type, proto)
+ sock = W_RSocket(family, s_type, proto)
except SocketError, e:
raise converted_error(space, e)
return space.wrap(sock)
@@ -651,7 +651,7 @@
[*] not available on all platforms!""",
__new__ = descr_socket_new,
__weakref__ = make_weakref_descr(W_RSocket),
- type = interp_attrproperty('type', W_RSocket),
+ s_type = interp_attrproperty('s_type', W_RSocket),
proto = interp_attrproperty('proto', W_RSocket),
family = interp_attrproperty('family', W_RSocket),
** socketmethods
diff --git a/rpython/rlib/rsocket.py b/rpython/rlib/rsocket.py
--- a/rpython/rlib/rsocket.py
+++ b/rpython/rlib/rsocket.py
@@ -480,17 +480,17 @@
"""
_mixin_ = True # for interp_socket.py
fd = _c.INVALID_SOCKET
- def __init__(self, family=AF_INET, type=SOCK_STREAM, proto=0,
+ def __init__(self, family=AF_INET, s_type=SOCK_STREAM, proto=0,
fd=_c.INVALID_SOCKET):
"""Create a new socket."""
if _c.invalid_socket(fd):
- fd = _c.socket(family, type, proto)
+ fd = _c.socket(family, s_type, proto)
if _c.invalid_socket(fd):
raise self.error_handler()
# PLAT RISCOS
self.fd = fd
self.family = family
- self.type = type
+ self.s_type = s_type
self.proto = proto
self.timeout = defaults.timeout
@@ -710,7 +710,7 @@
fd = _c.dup(self.fd)
if fd < 0:
raise self.error_handler()
- return make_socket(fd, self.family, self.type, self.proto,
+ return make_socket(fd, self.family, self.s_type, self.proto,
SocketClass=SocketClass)
def getpeername(self):
@@ -954,11 +954,11 @@
# ____________________________________________________________
-def make_socket(fd, family, type, proto, SocketClass=RSocket):
+def make_socket(fd, family, s_type, proto, SocketClass=RSocket):
result = instantiate(SocketClass)
result.fd = fd
result.family = family
- result.type = type
+ result.s_type = s_type
result.proto = proto
result.timeout = defaults.timeout
return result
@@ -1025,9 +1025,9 @@
socketpair_default_family = AF_UNIX
if hasattr(_c, 'socketpair'):
- def socketpair(family=socketpair_default_family, type=SOCK_STREAM, proto=0,
+ def socketpair(family=socketpair_default_family, s_type=SOCK_STREAM, proto=0,
SocketClass=RSocket):
- """socketpair([family[, type[, proto]]]) -> (socket object, socket object)
+ """socketpair([family[, s_type[, proto]]]) -> (socket object, socket object)
Create a pair of socket objects from the sockets returned by the platform
socketpair() function.
@@ -1035,14 +1035,14 @@
AF_UNIX if defined on the platform; otherwise, the default is AF_INET.
"""
result = lltype.malloc(_c.socketpair_t, 2, flavor='raw')
- res = _c.socketpair(family, type, proto, result)
+ res = _c.socketpair(family, s_type, proto, result)
if res < 0:
raise last_error()
fd0 = rffi.cast(lltype.Signed, result[0])
fd1 = rffi.cast(lltype.Signed, result[1])
lltype.free(result, flavor='raw')
- return (make_socket(fd0, family, type, proto, SocketClass),
- make_socket(fd1, family, type, proto, SocketClass))
+ return (make_socket(fd0, family, s_type, proto, SocketClass),
+ make_socket(fd1, family, s_type, proto, SocketClass))
if _c.WIN32:
def dup(fd):
@@ -1059,12 +1059,12 @@
def dup(fd):
return _c.dup(fd)
- def fromfd(fd, family, type, proto=0, SocketClass=RSocket):
+ def fromfd(fd, family, s_type, proto=0, SocketClass=RSocket):
# Dup the fd so it and the socket can be closed independently
fd = _c.dup(fd)
if fd < 0:
raise last_error()
- return make_socket(fd, family, type, proto, SocketClass)
+ return make_socket(fd, family, s_type, proto, SocketClass)
def getdefaulttimeout():
return defaults.timeout
More information about the pypy-commit
mailing list