bpo-34706: Preserve subclassing in inspect.Signature.from_callable (GH-16108) (GH-16113)

https://bugs.python.org/issue34706

Specifically in the case of a class that does not override its
constructor signature inherited from object.

These are Buck Evan @bukzor's changes cherrypicked from GH-9344.
(cherry picked from commit 5b9ff7a0dc)

Co-authored-by: Gregory P. Smith <greg@krypto.org>
This commit is contained in:
Miss Islington (bot) 2019-09-13 10:42:35 -07:00 committed by Stéphane Wirtel
parent 10873831ed
commit cf25765cf7
3 changed files with 11 additions and 3 deletions

View file

@ -2367,7 +2367,7 @@ def _signature_from_callable(obj, *,
if (obj.__init__ is object.__init__ and
obj.__new__ is object.__new__):
# Return a signature of 'object' builtin.
return signature(object)
return sigcls.from_callable(object)
else:
raise ValueError(
'no signature found for builtin type {!r}'.format(obj))