diff options
author | Martin v. Löwis <martin@v.loewis.de> | 2001-10-21 08:53:52 (GMT) |
---|---|---|
committer | Martin v. Löwis <martin@v.loewis.de> | 2001-10-21 08:53:52 (GMT) |
commit | 5b68ce3122a7663ca027a3e17e21d5d5561d09d9 (patch) | |
tree | 7eff721aa9f1bc61d6b65f31b7c8053f7843114d /Modules/pyexpat.c | |
parent | 6d204074cbd72bc671d1bdbb0d462ef3f0e49910 (diff) | |
download | cpython-5b68ce3122a7663ca027a3e17e21d5d5561d09d9.zip cpython-5b68ce3122a7663ca027a3e17e21d5d5561d09d9.tar.gz cpython-5b68ce3122a7663ca027a3e17e21d5d5561d09d9.tar.bz2 |
Change clear_handlers argument to indicate whether this is an initialization.
Do not set the Expat handlers if it is. Fixes PyXML bug #473195.
Diffstat (limited to 'Modules/pyexpat.c')
-rw-r--r-- | Modules/pyexpat.c | 19 |
1 files changed, 10 insertions, 9 deletions
diff --git a/Modules/pyexpat.c b/Modules/pyexpat.c index b55af8d..db4333c 100644 --- a/Modules/pyexpat.c +++ b/Modules/pyexpat.c @@ -290,12 +290,12 @@ conv_string_len_to_utf8(const XML_Char *str, int len) /* Callback routines */ -static void clear_handlers(xmlparseobject *self, int decref); +static void clear_handlers(xmlparseobject *self, int initial); static void flag_error(xmlparseobject *self) { - clear_handlers(self, 1); + clear_handlers(self, 0); } static PyCodeObject* @@ -1017,7 +1017,7 @@ xmlparse_ExternalEntityParserCreate(xmlparseobject *self, PyObject *args) Py_DECREF(new_parser); return PyErr_NoMemory(); } - clear_handlers(new_parser, 0); + clear_handlers(new_parser, 1); /* then copy handlers from self */ for (i = 0; handler_info[i].name != NULL; i++) { @@ -1193,7 +1193,7 @@ newxmlparseobject(char *encoding, char *namespace_separator) Py_DECREF(self); return PyErr_NoMemory(); } - clear_handlers(self, 0); + clear_handlers(self, 1); return (PyObject*)self; } @@ -1367,7 +1367,7 @@ xmlparse_traverse(xmlparseobject *op, visitproc visit, void *arg) static int xmlparse_clear(xmlparseobject *op) { - clear_handlers(op, 1); + clear_handlers(op, 0); return 0; } #endif @@ -1676,19 +1676,20 @@ MODULE_INITFUNC(void) } static void -clear_handlers(xmlparseobject *self, int decref) +clear_handlers(xmlparseobject *self, int initial) { int i = 0; PyObject *temp; for (; handler_info[i].name!=NULL; i++) { - if (decref) { + if (initial) + self->handlers[i]=NULL; + else { temp = self->handlers[i]; self->handlers[i] = NULL; Py_XDECREF(temp); + handler_info[i].setter(self->itself, NULL); } - self->handlers[i]=NULL; - handler_info[i].setter(self->itself, NULL); } } |