summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorSergey Shepelev <temotor@gmail.com>2016-05-24 12:59:47 +0500
committerSergey Shepelev <temotor@gmail.com>2016-05-24 13:03:04 +0500
commitd0837ba1cf8324d678b54567a7570421b7ede18c (patch)
tree56308f8bf00a2b4876b246d4e7243ea796c70546
parent8f3006554859b47b8af56be65506538fbc4e09ca (diff)
downloadeventlet-issue-319.tar.gz
socket: family kwarg name compatibilityissue-319
GreenSocket was (family_or_realsock=AF_INET, ...) which breaks code like socket(family=...) https://github.com/eventlet/eventlet/issues/319
-rw-r--r--eventlet/greenio/base.py8
-rw-r--r--tests/socket_test.py6
2 files changed, 10 insertions, 4 deletions
diff --git a/eventlet/greenio/base.py b/eventlet/greenio/base.py
index 60a8f29..5ed2593 100644
--- a/eventlet/greenio/base.py
+++ b/eventlet/greenio/base.py
@@ -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:
diff --git a/tests/socket_test.py b/tests/socket_test.py
index 5dea1b9..6bd32a8 100644
--- a/tests/socket_test.py
+++ b/tests/socket_test.py
@@ -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)