def getargspec_permissive(func):
if inspect.ismethod(func):<EOL><INDENT>func = func.im_func<EOL><DEDENT>if not (hasattr(func, "<STR_LIT>") and hasattr(func, "<STR_LIT>")):<EOL><INDENT>raise TypeError('<STR_LIT>'.format(func))<EOL><DEDENT>args, varargs, varkw = inspect.getargs(func.func_code)<EOL>return inspect.ArgSpec(args, varargs, varkw, func.func_defaults)<EOL>
An `inspect.getargspec` with a relaxed sanity check to support Cython.

Motivation:

    A Cython-compiled function is *not* an instance of Python's
    types.FunctionType.  That is the sanity check the standard Py2
    library uses in `inspect.getargspec()`.  So, an exception is raised
    when calling `argh.dispatch_command(cythonCompiledFunc)`.  However,
    the CyFunctions do have perfectly usable `.func_code` and
    `.func_defaults` which is all `inspect.getargspec` needs.

    This function just copies `inspect.getargspec()` from the standard
    library but relaxes the test to a more duck-typing one of having
    both `.func_code` and `.func_defaults` attributes.