[New-bugs-announce] [issue20473] inspect.Signature no longer handles builtin classes correctly
Larry Hastings
report at bugs.python.org
Sat Feb 1 04:42:17 CET 2014
New submission from Larry Hastings:
Yury: In revision 9433b380ad33 you changed inspect.Signature so that it cannot handle builtin classes. Please fix it.
>>> import _pickle
>>> import inspect
>>> str(inspect.signature(_pickle.Pickler))
'()'
>>> _pickle.Pickler.__text_signature__
'(file, protocol=None, fix_imports=True)'
Those two strings should be the same.
I don't know any guaranteed way to tell a builtin class from a
user class. So if you pass in a class, the best approach is to
do what it used to do: try from_builtin, and if it fails fail over
to the isinstance(obj, type) code. You changed it to
if _signature_is_builtin(obj):
return Signature.from_builtin(obj)
This unambiguously returns the result from from_builtin. Either
find a way that you can determine a class is a builtin 100%
reliably, or change this to *try* from_builtin but only return its
result if it's successful.
Your changes might have also caused #20471; that wasn't failing before. I'm still investigating.
----------
assignee: yselivanov
messages: 209871
nosy: larry, yselivanov
priority: normal
severity: normal
stage: needs patch
status: open
title: inspect.Signature no longer handles builtin classes correctly
type: behavior
versions: Python 3.4
_______________________________________
Python tracker <report at bugs.python.org>
<http://bugs.python.org/issue20473>
_______________________________________
More information about the New-bugs-announce
mailing list