At 09:11 PM 1/3/2007 -0800, Guido van Rossum wrote: >On 1/3/07, Phillip J. Eby <[EMAIL PROTECTED]> wrote: >>Or perhaps translate blocks of the form: >> >> except ExcType, e: >> # body >> >>to: >> >> except ExcType, e: >> try: >> # body >> finally: >> del e >> >>This won't stop you from creating a cycle explicitly, of course, but it >>would ensure that the simple cases would be cycle-free. > >+1! > >I used to dislike this because there are use cases for letting the >exception survive the except clause, but I think I can get used to it, >and it seems the most straightforward solution of all that I've seen. >We could completely get rid of sys.exc_info()! I think we have a >winner here.
Actually, on second thought it occurs to me that the above code isn't a 100% correct translation, because if "body" contains its own "del e", then it will fail. So a pure translation strategy isn't really practical, unfortunately. We'd have to generate something like: if 'e' in locals(): del e or add a new bytecode that's equivalent to that. >Explicitly created cycles are no big deal IMO -- these are no worse >than current code that explicitly stores sys.exc_info()[2]. True, but now they get that overhead simply by storing the exception object. On the other hand, I suppose code that might store a lot of exception objects will just have to be careful to clear tracebacks it doesn't need. _______________________________________________ Python-3000 mailing list Python-3000@python.org http://mail.python.org/mailman/listinfo/python-3000 Unsubscribe: http://mail.python.org/mailman/options/python-3000/archive%40mail-archive.com