Like Dennis' patch, mine changes PyErr_SetObject. The difference is that Dennis' patch gets rid of the cycle while mine leaves it as it is, just avoids hanging on it.
So in this case:
when trying to set the exception A on top of
B -> C -> D -> E -> C -> ...,
The result would be simply
A -> B -> C -> D -> E -> C -> ...,
As I said in msg391637, a pre-existing cycle is due to a bug somewhere, and I don't think PyErr_SetObject can or should try to fix that bug. Nonsense in, nonsense out. If we change it we probably just make it more nonsensical. |