Re: [Python-Dev] Re-raise in absence of an "active" exception

"Martin v. Löwis" [mailto:martin@v.loewis.de] wrote:
I'm actually surprised that the exception is cleared when the function that has the exception handler completes. Where does that happen? The current exception is in the thread state, not in the frame, after all.
eval_frame calls set_exc_info and reset_exc_info to do a save/restore to the frame object. Effectively there's a stack of exceptions, but since it's bound to frames interesting cases like this occur: try: point_A except: try: point_B except: pass raise ==> NameError: name 'point_B' is not defined (Refugees from C++ might expect the 'point_A' exception instead.) Method extraction brings the frame object into play for a different result: def b(): try: point_B except: pass try: point_A except: b() raise ==> NameError: name 'point_A' is not defined - Anders
participants (1)
-
Anders J. Munch