8000 gh-92123: Convert `_elementtree` types to heap types by erlend-aasland · Pull Request #99221 · python/cpython · GitHub
[go: up one dir, main page]

Skip to content

gh-92123: Convert _elementtree types to heap types #99221

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 22 commits into from
Jan 20, 2023
Merged
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
Fetch type before GC
  • Loading branch information
Erlend E. Aasland committed Jan 11, 2021
commit 525cfaff13289d39d0cd1a5fb051f1117ff5ca81
11 changes: 5 additions & 6 deletions Modules/_elementtree.c
Original file line number Diff line number Diff line change
Expand Up @@ -664,6 +664,8 @@ element_gc_clear(ElementObject *self)
static void
element_dealloc(ElementObject* self)
{
PyTypeObject *tp = Py_TYPE(self);

/* bpo-31095: UnTrack is needed before calling any callbacks */
PyObject_GC_UnTrack(self);
Py_TRASHCAN_BEGIN(self, element_dealloc)
Expand All @@ -676,7 +678,6 @@ element_dealloc(ElementObject* self)
element_gc_clear(self);

RELEASE(sizeof(ElementObject), "destroy element");
PyTypeObject *tp = Py_TYPE(self);
tp->tp_free(self);
Py_DECREF(tp);
Py_TRASHCAN_END
Expand Down Expand Up @@ -2083,6 +2084,7 @@ typedef struct {
static void
elementiter_dealloc(ElementIterObject *it)
{
PyTypeObject *tp = Py_TYPE(it);
Py_ssize_t i = it->parent_stack_used;
it->parent_stack_used = 0;
/* bpo-31095: UnTrack is needed before calling any callbacks */
Expand All @@ -2095,7 +2097,6 @@ elementiter_dealloc(ElementIterObject *it)
Py_XDECREF(it->root_element);

PyObject_GC_Del(it);
PyTypeObject *tp = Py_TYPE(it);
Py_DECREF(tp);
}

Expand Down Expand Up @@ -2467,10 +2468,9 @@ treebuilder_gc_clear(TreeBuilderObject *self)
static void
treebuilder_dealloc(TreeBuilderObject *self)
{
PyTypeObject *tp = Py_TYPE(self);
PyObject_GC_UnTrack(self);
treebuilder_gc_clear(self);

PyTypeObject *tp = Py_TYPE(self);
tp->tp_free(self);
Py_DECREF(tp);
}
Expand Down Expand Up @@ -3784,10 +3784,9 @@ xmlparser_gc_clear(XMLParserObject *self)
static void
xmlparser_dealloc(XMLParserObject* self)
{
PyTypeObject *tp = Py_TYPE(self);
PyObject_GC_UnTrack(self);
xmlparser_gc_clear(self);

PyTypeObject *tp = Py_TYPE(self);
tp->tp_free(self);
Py_DECREF(tp);
}
Expand Down
0