In article <[EMAIL PROTECTED]>, System Administrator <[EMAIL PROTECTED]> wrote: > > >> 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: > > Paul> That is impossible. The parameter to the raise statement is a > Paul> class object, which can be anything. > >Sure, but in all but the rarest of cases the first arg to raise is a >specific exception, probably one of the standard exceptions. In the Python >code in the distribution (ignoring the test directory where all sorts of >mischief is done to stress things), here are the most common words following >"raise" where "raise" is the first word on the line: > > % find . -name '*.py' \ > > | egrep -v '\./test' \ > > | xargs egrep '^ *raise ' \ > > | awk '{print $3}' \ > > | sed -e 's/[(,].*//' \ > > | sort \ > > | uniq -c \ > > | sort -rn \ > > | head -15 > 246 ValueError > 227 aetools.Error > 216 Error > 124 TypeError > 101 error > 75 RuntimeError > 53 IOError > 36 NotImplementedError > 36 ImportError > 36 EOFError > 31 SyntaxError > 23 KeyError > 23 AttributeError > 22 DistutilsPlatformError > 21 UnicodeError
It's kind of interesting (scarry?) that in roughly 20% of the cases nothing more specific than Error is raised. -- http://mail.python.org/mailman/listinfo/python-list