[issue21399] inspect and class methods
Yury Selivanov
report at bugs.python.org
Wed Apr 30 18:40:58 CEST 2014
Yury Selivanov added the comment:
> In Python2.7, the cls parameter shows up in pydoc:
>
> frombuf(cls, buf) from __builtin__.type
> Construct a TarInfo object from a 512 byte string buffer.
>
>
> In 3.5, it doesn't:
>
> frombuf(buf, encoding, errors) from builtins.type
> Construct a TarInfo object from a 512 byte bytes object.
Yes, that's a correct behaviour in 3.4 and 3.5. See #20710 for details.
> >>> signature(TarInfo.create_gnu_header)
> <Signature at 0x7f50cf110cf0 "(self, info, encoding, errors)">
> >>> signature(TarInfo.frombuf)
> <Signature at 0x7f50cf11cc88 "(buf, encoding, errors)">
There is no bug here. `TarInfo.create_gnu_header` is an unbound method, that indeed requires first argument 'self'. `TarInfo.frombuf` is a classmethod, so it doesn't need a 'cls' arg. Signature, by default and by design, only shows arguments that need to be passed to correctly execute the given callable.
> How about the C docstrings? Can we get "$cls" for classmethods?
Yes, I think it should work.
----------
nosy: +yselivanov
_______________________________________
Python tracker <report at bugs.python.org>
<http://bugs.python.org/issue21399>
_______________________________________
More information about the Python-bugs-list
mailing list