Conditional import of attributes.

This commit is contained in:
Ryan Williams
2010-02-27 17:59:50 -08:00
parent 9dfc3f7aca
commit cac3d24f2f

View File

@@ -14,14 +14,20 @@ import warnings
__patched__ = ['fromfd', 'socketpair', 'gethostbyname', 'create_connection',
'ssl', 'socket']
__original_fromfd__ = __socket.fromfd
def fromfd(*args):
return socket(__original_fromfd__(*args))
try:
__original_fromfd__ = __socket.fromfd
def fromfd(*args):
return socket(__original_fromfd__(*args))
except AttributeError:
pass
__original_socketpair__ = __socket.socketpair
def socketpair(*args):
one, two = __original_socketpair__(*args)
return socket(one), socket(two)
try:
__original_socketpair__ = __socket.socketpair
def socketpair(*args):
one, two = __original_socketpair__(*args)
return socket(one), socket(two)
except AttributeError:
pass
__original_gethostbyname__ = __socket.gethostbyname
def gethostbyname(name):