homepage

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 <1428943093.46.0.94678170323.issue23934@psf.upfronthosting.co.za>
In-reply-to
Content
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/inspect.py", line 2830, in signature
 return Signature.from_callable(obj)
 File "/home/ncoghlan/devel/py3k/Lib/inspect.py", line 2586, in from_callable
 return _signature_from_callable(obj, sigcls=cls)
 File "/home/ncoghlan/devel/py3k/Lib/inspect.py", line 2064, in _signature_from_callable
 skip_bound_arg=skip_bound_arg)
 File "/home/ncoghlan/devel/py3k/Lib/inspect.py", 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>
History
Date User Action Args
2015年04月13日 16:38:13ncoghlansetrecipients: + ncoghlan, larry, yselivanov, james
2015年04月13日 16:38:13ncoghlansetmessageid: <1428943093.46.0.94678170323.issue23934@psf.upfronthosting.co.za>
2015年04月13日 16:38:13ncoghlanlinkissue23934 messages
2015年04月13日 16:38:13ncoghlancreate

AltStyle によって変換されたページ (->オリジナル) /