This issue tracker has been migrated to GitHub, and is currently read-only.
For more information, see the GitHub FAQs in the Python's Developer Guide.

Author ncoghlan
Recipients james, larry, ncoghlan, yselivanov
Date 2015-04-13.16:38:13
SpamBayes Score -1.0
Marked as misclassified Yes
Message-id <>
inspect.signature isn't currently handling builtin & extension types correctly - these show up as having neither __new__ *nor* __init__ as pure Python callables, so the inspect.signature logic falls through into a currently unhandled case.

_testcapi isn't currently exporting an extension type as docstring introspection fodder, only callables, so test_inspect didn't pick up the problem. The problem can be seen with builtin types like str:

>>> import inspect
>>> inspect.signature(str)
<inspect.Signature object at 0x7fb81d44e518>
>>> print(inspect.signature(str))

Expected behaviour would be to throw a ValueError as with builtin callables without a signature:

>>> import _testcapi
>>> import inspect
>>> inspect.signature(_testcapi.docstring_no_signature)
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
  File "/home/ncoghlan/devel/py3k/Lib/", line 2830, in signature
    return Signature.from_callable(obj)
  File "/home/ncoghlan/devel/py3k/Lib/", line 2586, in from_callable
    return _signature_from_callable(obj, sigcls=cls)
  File "/home/ncoghlan/devel/py3k/Lib/", line 2064, in _signature_from_callable
  File "/home/ncoghlan/devel/py3k/Lib/", line 1984, in _signature_from_builtin
    raise ValueError("no signature found for builtin {!r}".format(func))
ValueError: no signature found for builtin <built-in function docstring_no_signature>
Date User Action Args
2015-04-13 16:38:13ncoghlansetrecipients: + ncoghlan, larry, yselivanov, james
2015-04-13 16:38:13ncoghlansetmessageid: <>
2015-04-13 16:38:13ncoghlanlinkissue23934 messages
2015-04-13 16:38:13ncoghlancreate