bpo-36370: Check for PyErr_Occurred() after PyImport_GetModule(). (GH-12504) by skrah · Pull Request #12504 · python/cpython

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Maybe, I updated the PR now because it's used in other places as well.

But PyErr_WriteUnraisable() contains a lot of code that could fail again; I'd be more comfortable in general with PyErr_Clear() and a simple fprintf().

On the other hand, in this particular case (thread finalization) stack exhaustion shouldn't be a problem.