Message402466
I am trying to define a type in C, that derives from PyTypeObject.
I want to override tp_clear. To do so properly, I should call base type's tp_clear and have it perform its cleanup steps. PyTypeObject has a tp_clear implementation: subtype_clear. Problem is, it assumes the instance it gets is of a type, that does not override PyTypeObject's tp_clear, and behaves incorrectly in 2 ways:
1) it does not perform the usual cleanup, because in this code
base = type;
while ((baseclear = base->tp_clear) == subtype_clear)
the loop condition is immediately false, as my types overrode tp_clear
2) later on it calls baseclear on the same object. But because of the loop above baseclear actually points to my type's custom tp_clear implementation, which leads to reentry to that function (basically a stack overflow, unless there's a guard against it). |
|
| Date |
User |
Action |
Args |
| 2021-09-22 19:16:19 | Victor Milovanov | set | recipients:
+ Victor Milovanov |
| 2021-09-22 19:16:19 | Victor Milovanov | set | messageid: <1632338179.69.0.00198937271084.issue45266@roundup.psfhosted.org> |
| 2021-09-22 19:16:19 | Victor Milovanov | link | issue45266 messages |
| 2021-09-22 19:16:19 | Victor Milovanov | create | |
|