'ensure all arguments have the requested type'

def _check_argument_types(self, spec=None, param=None):

    if (spec is None):
        spec = self.argument_spec
    if (param is None):
        param = self.params
    for (k, v) in spec.items():
        wanted = v.get('type', None)
        if (k not in param):
            continue
        value = param[k]
        if (value is None):
            continue
        if (not callable(wanted)):
            if (wanted is None):
                if (param[k] is None):
                    continue
                wanted = 'str'
            try:
                type_checker = self._CHECK_ARGUMENT_TYPES_DISPATCHER[wanted]
            except KeyError:
                self.fail_json(msg=('implementation    error:    unknown    type    %s    requested    for    %s' % (wanted, k)))
        else:
            type_checker = wanted
            wanted = getattr(wanted, '__name__', to_native(type(wanted)))
        try:
            param[k] = type_checker(value)
        except (TypeError, ValueError):
            e = get_exception()
            self.fail_json(msg=('argument    %s    is    of    type    %s    and    we    were    unable    to    convert    to    %s:    %s' % (k, type(value), wanted, e)))
