socket: family kwarg name compatibility
GreenSocket was (family_or_realsock=AF_INET, ...) which breaks code like socket(family=...) https://github.com/eventlet/eventlet/issues/319
This commit is contained in:
@@ -125,14 +125,14 @@ class GreenSocket(object):
|
||||
# This placeholder is to prevent __getattr__ from creating an infinite call loop
|
||||
fd = None
|
||||
|
||||
def __init__(self, family_or_realsock=socket.AF_INET, *args, **kwargs):
|
||||
def __init__(self, family=socket.AF_INET, *args, **kwargs):
|
||||
should_set_nonblocking = kwargs.pop('set_nonblocking', True)
|
||||
if isinstance(family_or_realsock, six.integer_types):
|
||||
fd = _original_socket(family_or_realsock, *args, **kwargs)
|
||||
if isinstance(family, six.integer_types):
|
||||
fd = _original_socket(family, *args, **kwargs)
|
||||
# Notify the hub that this is a newly-opened socket.
|
||||
notify_opened(fd.fileno())
|
||||
else:
|
||||
fd = family_or_realsock
|
||||
fd = family
|
||||
|
||||
# import timeout from other socket, if it was there
|
||||
try:
|
||||
|
@@ -43,3 +43,9 @@ def test_dns_methods_are_green():
|
||||
assert socket.gethostbyname_ex is greendns.gethostbyname_ex
|
||||
assert socket.getaddrinfo is greendns.getaddrinfo
|
||||
assert socket.getnameinfo is greendns.getnameinfo
|
||||
|
||||
|
||||
def test_socket_api_family():
|
||||
# It was named family_or_realsock
|
||||
# https://github.com/eventlet/eventlet/issues/319
|
||||
socket.socket(family=socket.AF_INET)
|
||||
|
Reference in New Issue
Block a user