Permalink
Browse files

pluginutils: fix check_arguments_compatibility

* Fixes a bug in check_arguments_compatibility when
  checking functions with empty default value specified.
  • Loading branch information...
1 parent c33ada5 commit 769479a3bd675523c86a38315bfa4e1f57bef50d @kaplun kaplun committed with tiborsimko Nov 18, 2011
Showing with 7 additions and 4 deletions.
  1. +7 −4 modules/miscutil/lib/pluginutils.py
@@ -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:

0 comments on commit 769479a

Please sign in to comment.