[pypy-svn] r18600 - pypy/dist/pypy/module/_socket
afa at codespeak.net
afa at codespeak.net
Sat Oct 15 11:02:43 CEST 2005
Author: afa
Date: Sat Oct 15 11:02:42 2005
New Revision: 18600
Modified:
pypy/dist/pypy/module/_socket/__init__.py
pypy/dist/pypy/module/_socket/app_socket.py
pypy/dist/pypy/module/_socket/interp_socket.py
Log:
(valentino, afa) moved socket.(set|get)defaulttimeout to applevel
Modified: pypy/dist/pypy/module/_socket/__init__.py
==============================================================================
--- pypy/dist/pypy/module/_socket/__init__.py (original)
+++ pypy/dist/pypy/module/_socket/__init__.py Sat Oct 15 11:02:42 2005
@@ -9,6 +9,8 @@
'herror' : 'app_socket.herror',
'gaierror' : 'app_socket.gaierror',
'timeout' : 'app_socket.timeout',
+ 'setdefaulttimeout' : 'app_socket.setdefaulttimeout',
+ 'getdefaulttimeout' : 'app_socket.getdefaulttimeout',
}
interpleveldefs = {
@@ -20,7 +22,6 @@
fromfd socketpair
ntohs ntohl htons htonl inet_aton inet_ntoa inet_pton inet_ntop
getaddrinfo getnameinfo
- getdefaulttimeout setdefaulttimeout
""".split():
if hasattr(_socket, name):
Modified: pypy/dist/pypy/module/_socket/app_socket.py
==============================================================================
--- pypy/dist/pypy/module/_socket/app_socket.py (original)
+++ pypy/dist/pypy/module/_socket/app_socket.py Sat Oct 15 11:02:42 2005
@@ -1,7 +1,10 @@
"""Implementation module for socket operations.
+NOT_RPYTHON
See the socket module for documentation."""
+defaulttimeout = -1 # Default timeout for new sockets
+
class error(Exception):
pass
@@ -18,3 +21,21 @@
pass
socket = SocketType
+
+def setdefaulttimeout(timeout):
+ if timeout is None:
+ timeout = -1.0
+ else:
+ if timeout < 0.0:
+ raise ValueError, "Timeout value out of range"
+
+ global defaulttimeout
+ defaulttimeout = timeout
+
+def getdefaulttimeout():
+ timeout = defaulttimeout
+
+ if timeout < 0.0:
+ return None
+ else:
+ return timeout
Modified: pypy/dist/pypy/module/_socket/interp_socket.py
==============================================================================
--- pypy/dist/pypy/module/_socket/interp_socket.py (original)
+++ pypy/dist/pypy/module/_socket/interp_socket.py Sat Oct 15 11:02:42 2005
@@ -338,24 +338,3 @@
raise wrap_socketerror(space, e)
getnameinfo.unwrap_spec = [ObjSpace, W_Root, int]
-def getdefaulttimeout(space):
- """getdefaulttimeout() -> timeout
-
- Returns the default timeout in floating seconds for new socket objects.
- A value of None indicates that new socket objects have no timeout.
- When the socket module is first imported, the default is None.
- """
- return space.wrap(socket.getdefaulttimeout())
-getdefaulttimeout.unwrap_spec = [ObjSpace]
-
-def setdefaulttimeout(space, w_timeout):
- """setdefaulttimeout(timeout)
-
- Set the default timeout in floating seconds for new socket objects.
- A value of None indicates that new socket objects have no timeout.
- When the socket module is first imported, the default is None.
- """
- timeout = space.unwrap(w_timeout)
- return space.wrap(socket.setdefaulttimeout(timeout))
-setdefaulttimeout.unwrap_spec = [ObjSpace, W_Root]
-
More information about the Pypy-commit
mailing list