diff options
author | Yury Selivanov <yselivanov@sprymix.com> | 2014-02-21 06:32:42 (GMT) |
---|---|---|
committer | Yury Selivanov <yselivanov@sprymix.com> | 2014-02-21 06:32:42 (GMT) |
commit | d224b6a796a8934b85b9a959c7a9e4b31d2bb428 (patch) | |
tree | 3037ae3f93fcc9e461efd1c744a3ff0e33699e23 /Lib/inspect.py | |
parent | b0b75a192215e87214f9f2c77d6839d2f83a5ea8 (diff) | |
download | cpython-d224b6a796a8934b85b9a959c7a9e4b31d2bb428.zip cpython-d224b6a796a8934b85b9a959c7a9e4b31d2bb428.tar.gz cpython-d224b6a796a8934b85b9a959c7a9e4b31d2bb428.tar.bz2 |
inspect: Fix getfullargspec to support builtin module-level functions. Issue #20711
Diffstat (limited to 'Lib/inspect.py')
-rw-r--r-- | Lib/inspect.py | 11 |
1 files changed, 9 insertions, 2 deletions
diff --git a/Lib/inspect.py b/Lib/inspect.py index 8b7840a..b85fbcc 100644 --- a/Lib/inspect.py +++ b/Lib/inspect.py @@ -1827,9 +1827,16 @@ def _signature_fromstr(cls, obj, s, skip_bound_arg=True): p(f.args.kwarg, empty) if self_parameter is not None: + # Possibly strip the bound argument: + # - We *always* strip first bound argument if + # it is a module. + # - We don't strip first bound argument if + # skip_bound_arg is False. assert parameters - if getattr(obj, '__self__', None) and skip_bound_arg: - # strip off self, it's already been bound + _self = getattr(obj, '__self__', None) + self_isbound = _self is not None + self_ismodule = ismodule(_self) + if self_isbound and (self_ismodule or skip_bound_arg): parameters.pop(0) else: # for builtins, self parameter is always positional-only! |