Switch get(full)argspec function according to python version
inspect.getargspec was deprecated since Python 3.0 and inspect.getfullargspec is its replacement with correct handling of function annotations and keyword-only parameters[1]. This change ensures that inspect.getfullargspec is used in Python 3. [1] https://docs.python.org/3/library/inspect.html#inspect.getargspec Change-Id: I63a4fda4f5da00c0f752e58f2e7192baea5012bb
This commit is contained in:
parent
653daf73ed
commit
e00ae03370
@ -933,9 +933,15 @@ def fake_http_connect(*code_iter, **kwargs):
|
||||
|
||||
if 'give_connect' in kwargs:
|
||||
give_conn_fn = kwargs['give_connect']
|
||||
argspec = inspect.getargspec(give_conn_fn)
|
||||
if argspec.keywords or 'connection_id' in argspec.args:
|
||||
ckwargs['connection_id'] = i
|
||||
|
||||
if six.PY2:
|
||||
argspec = inspect.getargspec(give_conn_fn)
|
||||
if argspec.keywords or 'connection_id' in argspec.args:
|
||||
ckwargs['connection_id'] = i
|
||||
else:
|
||||
argspec = inspect.getfullargspec(give_conn_fn)
|
||||
if argspec.varkw or 'connection_id' in argspec.args:
|
||||
ckwargs['connection_id'] = i
|
||||
give_conn_fn(*args, **ckwargs)
|
||||
etag = next(etag_iter)
|
||||
headers = next(headers_iter)
|
||||
|
Loading…
x
Reference in New Issue
Block a user