Python Code Auditing Tool

Robey Holderith robey at flaminglunchbox.net
Wed Feb 2 01:14:14 EST 2005


On Tue, 01 Feb 2005 21:52:28 -0800, Paul Rubin wrote:

> Robey Holderith <robey at flaminglunchbox.net> writes:
>> Does anybody know of a tool that can tell me all possible exceptions that
>> might occur in each line of code?  What I'm hoping to find is something
>> like the following:
> 
> That is impossible.  The parameter to the raise statement is a class
> object, which can be anything.  I.e. you could say:
> 
>    class ex1: pass
>    class ex2: pass
> 
>    if something(): my_ex = ex1
>    else: my_ex = ex2
> 
>    raise my_ex    # static tool can't know what exception gets raised here.

I suppose that I am willing to lessen my expectations from _all_ to most.
;-) Regarding your example I could also do:

    if something():
        def nothing(): return 0
    else:
        def nothing(): return 1

But this doesn't stop IDEs from attempting to do auto-completion.  I'm not
trying to find hidden exceptions... just trying to easily get an idea of
what could go wrong on each line of code.

-Robey Holderith




More information about the Python-list mailing list