Terry J. Reedy added the comment:
My first concern is whether this is a behavior issue that can be fixed in the
next 3.3 release or an enhancement request that should wait for 3.4.
If Signature.from_function were documented in the manual with the current
limitation, this issue would definitely be an enhancement request. But it is
not even mentioned in the manual. I presume this is intentional as it is pretty
clearly not meant to be called directly but only from signature(). Perhaps its
should have been given a leading underscore to mark it as private.
The docstring does say 'python function'. However, its type check is redundant
with the guard in signature before its call. So in normal usage, it can never
fail. Moreover, the limitation is completely unnecessary even for pure Python
code, as shown the the ease of creating a funclike class for the test. It is
contrary to Python policy and stdlib practice. So in a sense, it is a bug.
My conclusion: the proposed change is an enhancement bugfix (or bugfix
enhancement?) for an undocumented private function. So I think it ok for 3.3,
but would not blame anyone who disagreed.
---
I agree with Éric that the exception should not be changed, not just because it
would be a change, but because is would be a wrong change.
Signature.from_function(42) *is* a type error. The fact that the type error is
detected by attribute rather than by class is not relevant to external callers.
So please wrap the
# Parameter information.
section of the code with try: except AttributeError, as a substitute for the
current too-narrow type check. Leave the message as it, except possibly add the
object that fails:
"{} is not a function".format(func)
---
The change to signature has no effect on .from_function but makes it consistent
with the rest of the module.
----------
nosy: +terry.reedy
_______________________________________
Python tracker <[email protected]>
<http://bugs.python.org/issue17159>
_______________________________________
_______________________________________________
Python-bugs-list mailing list
Unsubscribe:
http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com