summaryrefslogtreecommitdiffstats
path: root/Lib/socket.py
diff options
context:
space:
mode:
authorChris Withers <chris@simplistix.co.uk>2009-04-11 11:22:19 (GMT)
committerChris Withers <chris@simplistix.co.uk>2009-04-11 11:22:19 (GMT)
commitb524825788847ac28d0bb56ea3c33d52bfe6798d (patch)
tree3ec8c3bf870789c8aa8e4c7767c44424e8e55272 /Lib/socket.py
parentf0f475da61b715ce6beda9f06516735193144d75 (diff)
downloadcpython-b524825788847ac28d0bb56ea3c33d52bfe6798d.zip
cpython-b524825788847ac28d0bb56ea3c33d52bfe6798d.tar.gz
cpython-b524825788847ac28d0bb56ea3c33d52bfe6798d.tar.bz2
remove unpleasant exec
Diffstat (limited to 'Lib/socket.py')
-rw-r--r--Lib/socket.py16
1 files changed, 11 insertions, 5 deletions
diff --git a/Lib/socket.py b/Lib/socket.py
index 7b37e90..5637fed 100644
--- a/Lib/socket.py
+++ b/Lib/socket.py
@@ -45,6 +45,8 @@ the setsockopt() and getsockopt() methods.
import _socket
from _socket import *
+from functools import partial
+from new import instancemethod
try:
import _ssl
@@ -213,11 +215,15 @@ class _socketobject(object):
type = property(lambda self: self._sock.type, doc="the socket type")
proto = property(lambda self: self._sock.proto, doc="the socket protocol")
- _s = ("def %s(self, *args): return self._sock.%s(*args)\n\n"
- "%s.__doc__ = _realsocket.%s.__doc__\n")
- for _m in _socketmethods:
- exec _s % (_m, _m, _m, _m)
- del _m, _s
+def meth(name,self,*args):
+ return getattr(self._sock,name)(*args)
+
+for _m in _socketmethods:
+ p = partial(meth,_m)
+ p.__name__ = _m
+ p.__doc__ = getattr(_realsocket,_m).__doc__
+ m = instancemethod(p,None,_socketobject)
+ setattr(_socketobject,_m,m)
socket = SocketType = _socketobject