diff options
author | Chris Withers <chris@simplistix.co.uk> | 2009-04-11 11:22:19 +0000 |
---|---|---|
committer | Chris Withers <chris@simplistix.co.uk> | 2009-04-11 11:22:19 +0000 |
commit | b524825788847ac28d0bb56ea3c33d52bfe6798d (patch) | |
tree | 3ec8c3bf870789c8aa8e4c7767c44424e8e55272 /Lib/socket.py | |
parent | f0f475da61b715ce6beda9f06516735193144d75 (diff) | |
download | cpython-git-b524825788847ac28d0bb56ea3c33d52bfe6798d.tar.gz |
remove unpleasant exec
Diffstat (limited to 'Lib/socket.py')
-rw-r--r-- | Lib/socket.py | 16 |
1 files changed, 11 insertions, 5 deletions
diff --git a/Lib/socket.py b/Lib/socket.py index 7b37e90aae..5637fed21c 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 |