bpo-33612: Remove PyThreadState_Clear() assertion by vstinner · Pull Request #7069 · python/cpython (original) (raw)
I agree, it is safe to clear just tstate->exc_state and remove the assertion.
Wait, do you mean that exc_state and/or exc_info must be explicitly cleared? These fields are pointers to data hold by a generator. The best that we can do is to set these pointers to NULL, but it is very likely the the whole tstate memory is going to be freed anyway, so I'm not sure that it's useful.
I'm not sure that I understood you correctly. Do you think that the current PR is correct? Or do we need extra changes?