mirror of
https://github.com/python/cpython.git
synced 2025-09-26 18:29:57 +00:00
remove unpleasant exec
This commit is contained in:
parent
f0f475da61
commit
b524825788
1 changed files with 11 additions and 5 deletions
|
@ -45,6 +45,8 @@ the setsockopt() and getsockopt() methods.
|
||||||
|
|
||||||
import _socket
|
import _socket
|
||||||
from _socket import *
|
from _socket import *
|
||||||
|
from functools import partial
|
||||||
|
from new import instancemethod
|
||||||
|
|
||||||
try:
|
try:
|
||||||
import _ssl
|
import _ssl
|
||||||
|
@ -213,11 +215,15 @@ class _socketobject(object):
|
||||||
type = property(lambda self: self._sock.type, doc="the socket type")
|
type = property(lambda self: self._sock.type, doc="the socket type")
|
||||||
proto = property(lambda self: self._sock.proto, doc="the socket protocol")
|
proto = property(lambda self: self._sock.proto, doc="the socket protocol")
|
||||||
|
|
||||||
_s = ("def %s(self, *args): return self._sock.%s(*args)\n\n"
|
def meth(name,self,*args):
|
||||||
"%s.__doc__ = _realsocket.%s.__doc__\n")
|
return getattr(self._sock,name)(*args)
|
||||||
for _m in _socketmethods:
|
|
||||||
exec _s % (_m, _m, _m, _m)
|
for _m in _socketmethods:
|
||||||
del _m, _s
|
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
|
socket = SocketType = _socketobject
|
||||||
|
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue