Renamed *args, **kwargs: bind correctly on Py2.7
Use search and inject Copied from the fuel-devops 3.0.3 Change-Id: Ibd454eb22b7bc534e790212cd536e553eed74ca8
This commit is contained in:
parent
e706a7b18d
commit
c3324fc7e4
@ -68,10 +68,21 @@ def _getcallargs(func, *positional, **named):
|
|||||||
if six.PY2:
|
if six.PY2:
|
||||||
# args and kwargs is not bound in py27
|
# args and kwargs is not bound in py27
|
||||||
# Note: py27 inspect is not unicode
|
# Note: py27 inspect is not unicode
|
||||||
if 'args' in orig_args:
|
missed = (
|
||||||
arguments[b'args'] = orig_args['args']
|
(key, val)
|
||||||
if 'kwargs' in orig_args:
|
for key, val in orig_args.items()
|
||||||
arguments[b'kwargs'] = orig_args['kwargs']
|
if key not in arguments)
|
||||||
|
args, kwargs = (), ()
|
||||||
|
for record in missed:
|
||||||
|
if isinstance(record[1], (list, tuple)):
|
||||||
|
args = record
|
||||||
|
elif isinstance(record[1], dict):
|
||||||
|
kwargs = record
|
||||||
|
|
||||||
|
if args:
|
||||||
|
arguments[args[0]] = args[1]
|
||||||
|
if kwargs:
|
||||||
|
arguments[kwargs[0]] = kwargs[1]
|
||||||
return arguments
|
return arguments
|
||||||
sig = inspect.signature(func).bind(*positional, **named)
|
sig = inspect.signature(func).bind(*positional, **named)
|
||||||
sig.apply_defaults() # after bind we doesn't have defaults
|
sig.apply_defaults() # after bind we doesn't have defaults
|
||||||
|
Loading…
Reference in New Issue
Block a user