Right now it may return `None` if no signature can be returned for the given builtin. If we decide to implement #17373 in 3.5, I'd like all three methods -- from_builtin, from_function, from_callable -- to either return a signature or to raise an exception.
This proposal and patch look good to me. The current behaviour definitely isn't desirable: >>> import inspect >>> inspect.Signature.from_function(1) Traceback (most recent call last): File "", line 1, in File "/home/ncoghlan/devel/py3k/Lib/inspect.py", line 1888, in from_function raise TypeError('{!r} is not a Python function'.format(func)) TypeError: 1 is not a Python function >>> inspect.Signature.from_builtin(1) >>> Signature.from_function() and Signature.from_builtin() should both also be documented, but we may want to wait for PEP 457 and #17373 in Python 3.5 before sorting all that out.
> Signature.from_function() and Signature.from_builtin() should both also be documented, but we may want to wait for PEP 457 and #17373 in Python 3.5 before sorting all that out. I would like to wait till 3.5 too. Right now both of them are sort of "private" API, so we still have the liberty to adjust their behaviour in 3.5 if needed.
History
Date
User
Action
Args
2022-04-11 14:57:57
admin
set
github: 64621
2014-01-29 15:49:12
yselivanov
set
messages: +
2014-01-29 15:47:10
yselivanov
set
status: open -> closedresolution: fixedmessages: +