*** pyexpat.c-orig Mon May 30 14:58:47 2005 --- pyexpat.c Tue May 31 01:46:19 2005 *************** *** 1064,1069 **** --- 1064,1106 ---- return Py_BuildValue("z", XML_GetBase(self->itself)); } + + PyDoc_STRVAR(xmlparse_ParserReset__doc__, + "ParserReset([encoding])\n\ + Clean up the memory structures maintained by the parser so that it may be used + again. After this has been called, parser is ready to start parsing a new + document. All handlers are cleared from the parser, except for the + unknownEncodingHandler. This function may not be used on a parser created using + XML_ExternalEntityParserCreate."); + + static PyObject * + xmlparse_ParserReset(xmlparseobject *self, PyObject *args) + { + char *encoding = NULL; + XML_Bool rb; + + if (!PyArg_ParseTuple(args, "|s:ParserReset", &encoding)) { + return NULL; + } + /* Clears out old hanlders and decrefs them */ + clear_handlers(self, 0); + + rb = XML_ParserReset(self->itself, encoding); + if (rb != XML_TRUE) { + return NULL; + } + /* ParserReset unsets userData as needed by handlers. Reset it. */ + XML_SetUserData(self->itself, (void *)self); + + /* How many of the struct elements do I need to reset? */ + Py_XDECREF(self->intern); + self->intern = PyDict_New(); + + Py_INCREF(Py_None); + return Py_None; + } + + PyDoc_STRVAR(xmlparse_GetInputContext__doc__, "GetInputContext() -> string\n\ Return the untranslated text of the input that caused the current event.\n\ *************** *** 1244,1249 **** --- 1281,1288 ---- METH_VARARGS, xmlparse_SetBase__doc__}, {"GetBase", (PyCFunction)xmlparse_GetBase, METH_VARARGS, xmlparse_GetBase__doc__}, + {"ParserReset",(PyCFunction)xmlparse_ParserReset, + METH_VARARGS, xmlparse_ParserReset__doc__}, {"ExternalEntityParserCreate", (PyCFunction)xmlparse_ExternalEntityParserCreate, METH_VARARGS, xmlparse_ExternalEntityParserCreate__doc__}, {"SetParamEntityParsing", (PyCFunction)xmlparse_SetParamEntityParsing,