[pypy-svn] r72408 - pypy/branch/kill-python-h/pypy/rlib
afa at codespeak.net
afa at codespeak.net
Fri Mar 19 13:07:09 CET 2010
Author: afa
Date: Fri Mar 19 13:07:07 2010
New Revision: 72408
Removed:
pypy/branch/kill-python-h/pypy/rlib/getaddrinfo.py
pypy/branch/kill-python-h/pypy/rlib/getnameinfo.py
Modified:
pypy/branch/kill-python-h/pypy/rlib/_rsocket_rffi.py
pypy/branch/kill-python-h/pypy/rlib/rsocket.py
Log:
At least since Visual Studio 8, getnameinfo() and getaddrinfo() are available.
Drop compatibility code for older compilers.
Also use rwin32.FormatError() instead of the hard-coded messages list.
Modified: pypy/branch/kill-python-h/pypy/rlib/_rsocket_rffi.py
==============================================================================
--- pypy/branch/kill-python-h/pypy/rlib/_rsocket_rffi.py (original)
+++ pypy/branch/kill-python-h/pypy/rlib/_rsocket_rffi.py Fri Mar 19 13:07:07 2010
@@ -448,13 +448,12 @@
socketconnect = external('connect', [socketfd_type, sockaddr_ptr, socklen_t], rffi.INT)
-if not WIN32:
- getaddrinfo = external('getaddrinfo', [CCHARP, CCHARP,
- addrinfo_ptr,
- lltype.Ptr(rffi.CArray(addrinfo_ptr))], rffi.INT)
- freeaddrinfo = external('freeaddrinfo', [addrinfo_ptr], lltype.Void)
- getnameinfo = external('getnameinfo', [sockaddr_ptr, socklen_t, CCHARP,
- size_t, CCHARP, size_t, rffi.INT], rffi.INT)
+getaddrinfo = external('getaddrinfo', [CCHARP, CCHARP,
+ addrinfo_ptr,
+ lltype.Ptr(rffi.CArray(addrinfo_ptr))], rffi.INT)
+freeaddrinfo = external('freeaddrinfo', [addrinfo_ptr], lltype.Void)
+getnameinfo = external('getnameinfo', [sockaddr_ptr, socklen_t, CCHARP,
+ size_t, CCHARP, size_t, rffi.INT], rffi.INT)
htonl = external('htonl', [rffi.UINT], rffi.UINT)
htons = external('htons', [rffi.USHORT], rffi.USHORT)
@@ -563,78 +562,14 @@
WSAGetLastError = external('WSAGetLastError', [], rffi.INT)
geterrno = WSAGetLastError
-
- import errno
- WIN32_ERROR_MESSAGES = {
- errno.WSAEINTR: "Interrupted system call",
- errno.WSAEBADF: "Bad file descriptor",
- errno.WSAEACCES: "Permission denied",
- errno.WSAEFAULT: "Bad address",
- errno.WSAEINVAL: "Invalid argument",
- errno.WSAEMFILE: "Too many open files",
- errno.WSAEWOULDBLOCK:
- "The socket operation could not complete without blocking",
- errno.WSAEINPROGRESS: "Operation now in progress",
- errno.WSAEALREADY: "Operation already in progress",
- errno.WSAENOTSOCK: "Socket operation on non-socket",
- errno.WSAEDESTADDRREQ: "Destination address required",
- errno.WSAEMSGSIZE: "Message too long",
- errno.WSAEPROTOTYPE: "Protocol wrong type for socket",
- errno.WSAENOPROTOOPT: "Protocol not available",
- errno.WSAEPROTONOSUPPORT: "Protocol not supported",
- errno.WSAESOCKTNOSUPPORT: "Socket type not supported",
- errno.WSAEOPNOTSUPP: "Operation not supported",
- errno.WSAEPFNOSUPPORT: "Protocol family not supported",
- errno.WSAEAFNOSUPPORT: "Address family not supported",
- errno.WSAEADDRINUSE: "Address already in use",
- errno.WSAEADDRNOTAVAIL: "Can't assign requested address",
- errno.WSAENETDOWN: "Network is down",
- errno.WSAENETUNREACH: "Network is unreachable",
- errno.WSAENETRESET: "Network dropped connection on reset",
- errno.WSAECONNABORTED: "Software caused connection abort",
- errno.WSAECONNRESET: "Connection reset by peer",
- errno.WSAENOBUFS: "No buffer space available",
- errno.WSAEISCONN: "Socket is already connected",
- errno.WSAENOTCONN: "Socket is not connected",
- errno.WSAESHUTDOWN: "Can't send after socket shutdown",
- errno.WSAETOOMANYREFS: "Too many references: can't splice",
- errno.WSAETIMEDOUT: "Operation timed out",
- errno.WSAECONNREFUSED: "Connection refused",
- errno.WSAELOOP: "Too many levels of symbolic links",
- errno.WSAENAMETOOLONG: "File name too long",
- errno.WSAEHOSTDOWN: "Host is down",
- errno.WSAEHOSTUNREACH: "No route to host",
- errno.WSAENOTEMPTY: "Directory not empty",
- errno.WSAEPROCLIM: "Too many processes",
- errno.WSAEUSERS: "Too many users",
- errno.WSAEDQUOT: "Disc quota exceeded",
- errno.WSAESTALE: "Stale NFS file handle",
- errno.WSAEREMOTE: "Too many levels of remote in path",
- errno.WSASYSNOTREADY: "Network subsystem is unvailable",
- errno.WSAVERNOTSUPPORTED: "WinSock version is not supported",
- errno.WSANOTINITIALISED: "Successful WSAStartup() not yet performed",
- errno.WSAEDISCON: "Graceful shutdown in progress",
-
- # Resolver errors
- # XXX Not exported by errno. Replace by the values in winsock.h
- # errno.WSAHOST_NOT_FOUND: "No such host is known",
- # errno.WSATRY_AGAIN: "Host not found, or server failed",
- # errno.WSANO_RECOVERY: "Unexpected server error encountered",
- # errno.WSANO_DATA: "Valid name without requested data",
- # errno.WSANO_ADDRESS: "No address, look for MX record",
-
- # select() errors
- WSA_IO_PENDING: "WSA_IO_PENDING",
- WSA_IO_INCOMPLETE: "WSA_IO_INCOMPLETE",
- WSA_INVALID_HANDLE: "WSA_INVALID_HANDLE",
- WSA_INVALID_PARAMETER: "WSA_INVALID_PARAMETER",
- WSA_NOT_ENOUGH_MEMORY: "WSA_NOT_ENOUGH_MEMORY",
- WSA_OPERATION_ABORTED: "WSA_OPERATION_ABORTED",
- }
- assert len(WIN32_ERROR_MESSAGES) == 53 # detect duplicates
+ from pypy.rlib import rwin32
def socket_strerror_str(errno):
- return WIN32_ERROR_MESSAGES.get(errno, "winsock error %d" % errno)
+ return rwin32.FormatError(errno)
+ def gai_strerror_str(errno):
+ return rwin32.FormatError(errno)
else:
socket_strerror_str = os.strerror
+ def gai_strerror_str(errno):
+ return rffi.charp2str(gai_strerror(self.errno))
Modified: pypy/branch/kill-python-h/pypy/rlib/rsocket.py
==============================================================================
--- pypy/branch/kill-python-h/pypy/rlib/rsocket.py (original)
+++ pypy/branch/kill-python-h/pypy/rlib/rsocket.py Fri Mar 19 13:07:07 2010
@@ -1040,8 +1040,7 @@
class GAIError(SocketErrorWithErrno):
applevelerrcls = 'gaierror'
def get_msg(self):
- # this method may be patched below
- return rffi.charp2str(_c.gai_strerror(self.errno))
+ return _c.gai_strerror_str(self.errno)
class HSocketError(SocketError):
applevelerrcls = 'herror'
@@ -1334,17 +1333,3 @@
if timeout < 0.0:
timeout = -1.0
defaults.timeout = timeout
-
-# _______________________________________________________________
-#
-# Patch module, for platforms without getaddrinfo / getnameinfo
-#
-
-if not getattr(_c, 'getaddrinfo', None):
- from pypy.rlib.getaddrinfo import getaddrinfo
- from pypy.rlib.getaddrinfo import GAIError_getmsg
- GAIError.get_msg = GAIError_getmsg
-
-if not getattr(_c, 'getnameinfo', None):
- from pypy.rlib.getnameinfo import getnameinfo
- from pypy.rlib.getnameinfo import NI_NUMERICHOST, NI_NUMERICSERV
More information about the Pypy-commit
mailing list