Skip to content
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
Next Next commit
bpo-42972: pyexpat
  • Loading branch information
Erlend E. Aasland committed May 26, 2021
commit fe9ef336ceaf9ba3b7788d639a6fad7653e256c7
39 changes: 18 additions & 21 deletions Modules/pyexpat.c
Original file line number Diff line number Diff line change
Expand Up @@ -1182,27 +1182,41 @@ newxmlparseobject(pyexpat_state *state, const char *encoding,
return (PyObject*)self;
}

static int
xmlparse_traverse(xmlparseobject *op, visitproc visit, void *arg)
{
for (int i = 0; handler_info[i].name != NULL; i++) {
Py_VISIT(op->handlers[i]);
}
Py_VISIT(Py_TYPE(op));
return 0;
}

static int
xmlparse_clear(xmlparseobject *op)
{
clear_handlers(op, 0);
Py_CLEAR(op->intern);
return 0;
}

static void
xmlparse_dealloc(xmlparseobject *self)
{
int i;
PyObject_GC_UnTrack(self);
if (self->itself != NULL)
XML_ParserFree(self->itself);
self->itself = NULL;
(void)xmlparse_clear(self);

if (self->handlers != NULL) {
for (i = 0; handler_info[i].name != NULL; i++)
Py_CLEAR(self->handlers[i]);
PyMem_Free(self->handlers);
self->handlers = NULL;
}
if (self->buffer != NULL) {
PyMem_Free(self->buffer);
self->buffer = NULL;
}
Py_XDECREF(self->intern);
PyTypeObject *tp = Py_TYPE(self);
PyObject_GC_Del(self);
Py_DECREF(tp);
Expand Down Expand Up @@ -1473,23 +1487,6 @@ static PyGetSetDef xmlparse_getsetlist[] = {
#undef XMLPARSE_GETTER_DEF
#undef XMLPARSE_GETTER_SETTER_DEF

static int
xmlparse_traverse(xmlparseobject *op, visitproc visit, void *arg)
{
int i;
for (i = 0; handler_info[i].name != NULL; i++)
Py_VISIT(op->handlers[i]);
return 0;
}

static int
xmlparse_clear(xmlparseobject *op)
{
clear_handlers(op, 0);
Py_CLEAR(op->intern);
return 0;
}

PyDoc_STRVAR(Xmlparsetype__doc__, "XML parser");

static PyType_Slot _xml_parse_type_spec_slots[] = {
Expand Down