Antoine Pitrou <[EMAIL PROTECTED]> added the comment:

You don't need to raise another exception, calling sys.exc_clear()
should be fine. But a cleaner way to write your example is:

def foo():
    with open("a.txt", "w") as io:
        raise RuntimeError()

"with" will automatically close the file when the block exits.
If you are concerned with Python < 2.5 compatibility, use "try: ...
finally:" instead.

And, you're right, the problem doesn't occur at all in Python 3.0
because the exception is cleaned up after the end of the "except:" block
catching it.

----------
nosy: +pitrou
resolution:  -> invalid
status: open -> closed

_______________________________________
Python tracker <[EMAIL PROTECTED]>
<http://bugs.python.org/issue3515>
_______________________________________
_______________________________________________
Python-bugs-list mailing list
Unsubscribe: 
http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com

Reply via email to