Skip to content

Commit

Permalink
pluginutils: fix check_arguments_compatibility
Browse files Browse the repository at this point in the history
* Fixes a bug in check_arguments_compatibility when
  checking functions with empty default value specified.
  • Loading branch information
kaplun authored and tiborsimko committed Nov 21, 2011
1 parent c33ada5 commit 769479a
Showing 1 changed file with 7 additions and 4 deletions.
11 changes: 7 additions & 4 deletions modules/miscutil/lib/pluginutils.py
Original file line number Diff line number Diff line change
Expand Up @@ -836,27 +836,30 @@ def check_arguments_compatibility(the_callable, argd):
argd = {}
args, dummy, varkw, defaults = inspect.getargspec(the_callable)
tmp_args = list(args)
optional_args = []
args_dict = {}
if defaults:
defaults = list(defaults)
else:
defaults = []
while defaults:
args_dict[tmp_args.pop()] = defaults.pop()
arg = tmp_args.pop()
optional_args.append(arg)
args_dict[arg] = defaults.pop()

while tmp_args:
args_dict[tmp_args.pop()] = None

for arg, value in argd.iteritems():
for arg, dummy_value in argd.iteritems():
if arg in args_dict:
del args_dict[arg]
elif not varkw:
raise ValueError('Argument %s not expected when calling callable '
'"%s" with arguments %s' % (
arg, get_callable_signature_as_string(the_callable), argd))

for arg, value in args_dict.items():
if value:
for arg in args_dict.keys():
if arg in optional_args:
del args_dict[arg]

if args_dict:
Expand Down

0 comments on commit 769479a

Please sign in to comment.