(original) (raw)

On 21 May 2012 03:36, Guido van Rossum <guido@python.org> wrote:
\[...\]

I have to agree with Christian that inspect.py is full of hacks and
heuristics that would be fine in a module that's part of a user's app
or even in a library, but stand out as brittle or outright unreliable
in a stdlib module. Basically, you can't trust that inspect.py will
work. I've seen various occasions (sorry, can't remember details)
where some function in it outright crashed when given a slightly
unusual (but not unreasonable) argument. It might be a nice project
for a new contributor to improve this situation.
\[...\]

An example that crashes is

 >>> def f(l, (x, y)):  
 ... sup = max(u\*x + v\*y for u, v in l)  
 ... return ((u, v) for u, v in l if u\*x + v\*y == sup)
>>> inspect.getargspec(f)

See http://bugs.python.org/issue14611 . I did submit a patch, a few weeks ago.

��� Stefano