This issue tracker has been migrated to GitHub, and is currently read-only.
For more information, see the GitHub FAQs in the Python's Developer Guide.

Author Victor Milovanov
Recipients Victor Milovanov
Date 2021-09-22.19:16:19
SpamBayes Score -1.0
Marked as misclassified Yes
Message-id <1632338179.69.0.00198937271084.issue45266@roundup.psfhosted.org>
In-reply-to
Content
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).
History
Date User Action Args
2021-09-22 19:16:19Victor Milovanovsetrecipients: + Victor Milovanov
2021-09-22 19:16:19Victor Milovanovsetmessageid: <1632338179.69.0.00198937271084.issue45266@roundup.psfhosted.org>
2021-09-22 19:16:19Victor Milovanovlinkissue45266 messages
2021-09-22 19:16:19Victor Milovanovcreate