diff --git a/tests/utils.py b/tests/utils.py index 1bf6817..97d6699 100644 --- a/tests/utils.py +++ b/tests/utils.py @@ -54,13 +54,13 @@ def getcontents( '\r\n'.join(headers), data).encode('latin-1') + family = socket.AF_INET + if ':' in host: if host == '::': - host = 'localhost' - - family = socket.AF_INET6 - else: - family = socket.AF_INET + host = '127.0.0.1' + else: + family = socket.AF_INET6 with socket.socket(family, socket.SOCK_STREAM) as sock: sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) diff --git a/tremolo/tremolo.py b/tremolo/tremolo.py index efab4d9..373c650 100644 --- a/tremolo/tremolo.py +++ b/tremolo/tremolo.py @@ -163,12 +163,14 @@ def on_response(self, *args): def getoptions(self, func): options = {} + arg_count = func.__code__.co_argcount if func.__defaults__ is not None: - options = dict(zip( - func.__code__.co_varnames[:len(func.__defaults__)], - func.__defaults__ - )) + arg_count -= len(func.__defaults__) + + for i, name in enumerate(func.__code__.co_varnames[ + arg_count:func.__code__.co_argcount]): + options[name] = func.__defaults__[i] return options