how does exception mechanism work?

Paul Rubin http
Mon Dec 12 04:46:45 EST 2005


bobueland at yahoo.com writes:
> Is this model correct or wrong? Where can I read about the mechanism
> behind exceptions?

Usually you push exception handlers and "finally" clauses onto the
activation stack like you push return addresses for function calls.
When something raises an exception, you scan the activation stack
backwards, popping stuff from it as you scan and executing "finally"
clauses as you find them, until you find a handler for the raised
exception.

Good book: "Structure and Interpretation of Computer Programming"
by Abelson and Sussman,

  http://mitpress.mit.edu/sicp/

It explains all this stuff (uses a different language from Python, but
principles are similar).  Full text is online.



More information about the Python-list mailing list