I read the patch but I don't understand the logic behind it :-). Why should the value of tstate->exc_type affect whether we save/restore exc_info? Won't this mean that things are still broken for code like:
-----
def f():
try:
raise KeyError
except Exception:
try:
yield
except Exception:
pass
raise
try:
raise NameError
except Exception:
gen = f()
gen.send(None)
gen.throw(ValueError)
-----
?
Conceptually I would have thought the fix would be to remove the '!throwflag' check, but I haven't actually tried it...