diff -r d57df3f72715 Lib/inspect.py --- a/Lib/inspect.py Thu Feb 20 20:53:27 2014 -0500 +++ b/Lib/inspect.py Fri Feb 21 00:02:36 2014 -0500 @@ -1827,9 +1827,16 @@ 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! diff -r d57df3f72715 Lib/test/test_inspect.py --- a/Lib/test/test_inspect.py Thu Feb 20 20:53:27 2014 -0500 +++ b/Lib/test/test_inspect.py Fri Feb 21 00:02:36 2014 -0500 @@ -643,6 +643,13 @@ self.assertFullArgSpecEquals(_pickle.Pickler(io.BytesIO()).dump, args_e=['self', 'obj'], formatted='(self, obj)') + self.assertFullArgSpecEquals( + os.stat, + args_e=['path'], + kwonlyargs_e=['dir_fd', 'follow_symlinks'], + kwonlydefaults_e={'dir_fd': None, 'follow_symlinks': True}, + formatted='(path, *, dir_fd=None, follow_symlinks=True)') + @cpython_only @unittest.skipIf(MISSING_C_DOCSTRINGS, "Signature information for builtins requires docstrings")