those darn exceptions

Chris Angelico rosuav at gmail.com
Fri Jun 24 23:55:49 EDT 2011


On Sat, Jun 25, 2011 at 10:25 AM, Ben Finney <ben+python at benfinney.id.au> wrote:
> No. The answer is *still* “why, any exception at all”. The name
> ‘os.read’ could be re-bound at run-time to any object at all, so a code
> checker that you “point at any given line of code” can't know what the
> name will be bound to when that line gets executed.

Sure it can. And KeyboardInterrupt could be raised at any time, too.
But this is a TOOL, not a deity. If Function X is known to call
Function Y and built-in method Z, and also raises FooException, then
X's list of "most likely exceptions" would be FooException +
Y.__exceptions__ + Z.__exceptions__. It won't be perfect, but it'd be
something that could go into an autodoc-style facility. Obviously you
can fiddle with things, but in _ordinary usage_ this is what it's
_most likely_ to produce.

Chris Angelico



More information about the Python-list mailing list