Yury Selivanov added the comment:

>> Otherwise we run the risk of introducing unexpected exceptions into 
>> introspection code.

> That's a good catch. I'll make a new patch, keeping the old implementation of 
> getfullargsspec intact, and falling back to it if no signature can be found.

Nick, while I was working on the second patch (writing a new unittest for it 
specifically), I realized, that it's not that easy to make the old version of 
"getfullargsspec" to spit out any exception that it doesn't currently do with 
the proposed 'getargsspec_01.patch'.

See, the old "getfullargsspec" does the following:

1. Check if the passed object is a function, with 'inspect.isfunction'. If not 
- throw a TypeError.  That behaviour is duplicated in the patch, so we are safe 
here.

2. Call on the object's __code__ '_getfullargs', which validates that the 
passed code object is a valid code object, and simply returns its attributes 
rearranged a bit.

Now, to have any exception in (2), we need: either a broken __code__ object, or 
something that is an instance of "types.FunctionType" (hence, defined in 
python) but doesn't have the "__code__" attribute. And that's kind of hard to 
achieve.

----------

_______________________________________
Python tracker <rep...@bugs.python.org>
<http://bugs.python.org/issue17481>
_______________________________________
_______________________________________________
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com

Reply via email to