diff options
author | Fred Drake <fdrake@acm.org> | 2004-08-13 03:12:57 (GMT) |
---|---|---|
committer | Fred Drake <fdrake@acm.org> | 2004-08-13 03:12:57 (GMT) |
commit | 39689c5c6a2a3f1a9135d62b427032a3c4eae053 (patch) | |
tree | 9e1e7b26ddb0beb0a67f03396daa939f51f6c256 | |
parent | d7ea55b1b83a48503f7fb48517ae61a8c54ee3c5 (diff) | |
download | cpython-39689c5c6a2a3f1a9135d62b427032a3c4eae053.zip cpython-39689c5c6a2a3f1a9135d62b427032a3c4eae053.tar.gz cpython-39689c5c6a2a3f1a9135d62b427032a3c4eae053.tar.bz2 |
make exception propogation more efficient; this avoids having Expat parse
the remaining data in the buffer (which it had done happily without reporting
any results)
this depends on a new feature in Expat added in 1.95.8
-rw-r--r-- | Modules/pyexpat.c | 12 |
1 files changed, 7 insertions, 5 deletions
diff --git a/Modules/pyexpat.c b/Modules/pyexpat.c index 23d0e2d..3bee0ac 100644 --- a/Modules/pyexpat.c +++ b/Modules/pyexpat.c @@ -357,7 +357,8 @@ trace_frame_exc(PyThreadState *tstate, PyFrameObject *f) #endif static PyObject* -call_with_frame(PyCodeObject *c, PyObject* func, PyObject* args) +call_with_frame(PyCodeObject *c, PyObject* func, PyObject* args, + xmlparseobject *self) { PyThreadState *tstate = PyThreadState_GET(); PyFrameObject *f; @@ -379,6 +380,7 @@ call_with_frame(PyCodeObject *c, PyObject* func, PyObject* args) if (res == NULL) { if (tstate->curexc_traceback == NULL) PyTraceBack_Here(f); + XML_StopParser(self->itself, XML_FALSE); #ifdef FIX_TRACE if (trace_frame_exc(tstate, f) < 0) { return NULL; @@ -453,7 +455,7 @@ call_character_handler(xmlparseobject *self, const XML_Char *buffer, int len) /* temp is now a borrowed reference; consider it unused. */ self->in_callback = 1; temp = call_with_frame(getcode(CharacterData, "CharacterData", __LINE__), - self->handlers[CharacterData], args); + self->handlers[CharacterData], args, self); /* temp is an owned reference again, or NULL */ self->in_callback = 0; Py_DECREF(args); @@ -574,7 +576,7 @@ my_StartElementHandler(void *userData, /* Container is now a borrowed reference; ignore it. */ self->in_callback = 1; rv = call_with_frame(getcode(StartElement, "StartElement", __LINE__), - self->handlers[StartElement], args); + self->handlers[StartElement], args, self); self->in_callback = 0; Py_DECREF(args); if (rv == NULL) { @@ -601,7 +603,7 @@ my_##NAME##Handler PARAMS {\ if (!args) { flag_error(self); return RETURN;} \ self->in_callback = 1; \ rv = call_with_frame(getcode(NAME,#NAME,__LINE__), \ - self->handlers[NAME], args); \ + self->handlers[NAME], args, self); \ self->in_callback = 0; \ Py_DECREF(args); \ if (rv == NULL) { \ @@ -758,7 +760,7 @@ my_ElementDeclHandler(void *userData, } self->in_callback = 1; rv = call_with_frame(getcode(ElementDecl, "ElementDecl", __LINE__), - self->handlers[ElementDecl], args); + self->handlers[ElementDecl], args, self); self->in_callback = 0; if (rv == NULL) { flag_error(self); |