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:
@@ -933,9 +933,15 @@ def fake_http_connect(*code_iter, **kwargs):
|
|||||||
|
|
||||||
if 'give_connect' in kwargs:
|
if 'give_connect' in kwargs:
|
||||||
give_conn_fn = kwargs['give_connect']
|
give_conn_fn = kwargs['give_connect']
|
||||||
|
|
||||||
|
if six.PY2:
|
||||||
argspec = inspect.getargspec(give_conn_fn)
|
argspec = inspect.getargspec(give_conn_fn)
|
||||||
if argspec.keywords or 'connection_id' in argspec.args:
|
if argspec.keywords or 'connection_id' in argspec.args:
|
||||||
ckwargs['connection_id'] = i
|
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)
|
give_conn_fn(*args, **ckwargs)
|
||||||
etag = next(etag_iter)
|
etag = next(etag_iter)
|
||||||
headers = next(headers_iter)
|
headers = next(headers_iter)
|
||||||
|
|||||||
Reference in New Issue
Block a user