[Python-Dev] dir() in inspect.py ?

Stefano Taschini taschini at ieee.org
Mon May 21 07:52:05 CEST 2012


On 21 May 2012 03:36, Guido van Rossum <guido at 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
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.python.org/pipermail/python-dev/attachments/20120521/8c6fd353/attachment.html>


More information about the Python-Dev mailing list