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', __patched__ = ['fromfd', 'socketpair', 'gethostbyname', 'create_connection',
'ssl', 'socket'] 'ssl', 'socket']
__original_fromfd__ = __socket.fromfd try:
def fromfd(*args): __original_fromfd__ = __socket.fromfd
return socket(__original_fromfd__(*args)) def fromfd(*args):
return socket(__original_fromfd__(*args))
except AttributeError:
pass
__original_socketpair__ = __socket.socketpair try:
def socketpair(*args): __original_socketpair__ = __socket.socketpair
one, two = __original_socketpair__(*args) def socketpair(*args):
return socket(one), socket(two) one, two = __original_socketpair__(*args)
return socket(one), socket(two)
except AttributeError:
pass
__original_gethostbyname__ = __socket.gethostbyname __original_gethostbyname__ = __socket.gethostbyname
def gethostbyname(name): def gethostbyname(name):