Re: try: execpt:/ try: finally: behavior

Chris Hoffmann (
Tue, 21 Jun 94 17:54:10 EDT

Just my 2 cents here, but the examples work exactly the way I would
expect (and most likely want) them to.

If the code in the finally suite could potentially raise an
exception, and you don't want that exception to mask any exception
raised in the try suite, then it seems to me that it is up to you to
prevent that.

I hope someone can fill in the exact syntax (I haven't done anything
this fancy with exceptions), but isn't it possible to do code like:

# save any exception that may have occurred
# have to save value as well of course
first_exception = sys.last_exception
print x/0
if first_exception: # raise original exception
raise first_exception
elif sys.last_exception: # raise ZeroDivision exception
raise sys.last_exception
# else no exceptions, so pass


Chris Hoffmann VI Corporation 47 Pleasant St. Northampton MA 01060