[Python-checkins] cpython: Issue #18501, #18408: Fix expat handlers in pyexpat, don't call Python

victor.stinner python-checkins at python.org
Thu Jul 18 23:43:44 CEST 2013


http://hg.python.org/cpython/rev/5a6cdc0d7de1
changeset:   84710:5a6cdc0d7de1
user:        Victor Stinner <victor.stinner at gmail.com>
date:        Thu Jul 18 23:17:01 2013 +0200
summary:
  Issue #18501, #18408: Fix expat handlers in pyexpat, don't call Python
functions if a Python exception was raised

files:
  Modules/pyexpat.c |  15 +++++++++++++++
  1 files changed, 15 insertions(+), 0 deletions(-)


diff --git a/Modules/pyexpat.c b/Modules/pyexpat.c
--- a/Modules/pyexpat.c
+++ b/Modules/pyexpat.c
@@ -402,6 +402,10 @@
 my_CharacterDataHandler(void *userData, const XML_Char *data, int len)
 {
     xmlparseobject *self = (xmlparseobject *) userData;
+
+    if (PyErr_Occurred())
+        return;
+
     if (self->buffer == NULL)
         call_character_handler(self, data, len);
     else {
@@ -436,6 +440,9 @@
         PyObject *container, *rv, *args;
         int i, max;
 
+        if (PyErr_Occurred())
+            return;
+
         if (flush_character_buffer(self) < 0)
             return;
         /* Set max to the number of slots filled in atts[]; max/2 is
@@ -519,6 +526,8 @@
     INIT \
 \
     if (have_handler(self, NAME)) { \
+        if (PyErr_Occurred()) \
+            return RETURN; \
         if (flush_character_buffer(self) < 0) \
             return RETURN; \
         args = Py_BuildValue PARAM_FORMAT ;\
@@ -633,6 +642,9 @@
         PyObject *rv = NULL;
         PyObject *modelobj, *nameobj;
 
+        if (PyErr_Occurred())
+            return;
+
         if (flush_character_buffer(self) < 0)
             goto finally;
         modelobj = conv_content_model(model, (conv_string_to_unicode));
@@ -1125,6 +1137,9 @@
     void *data;
     unsigned int kind;
 
+    if (PyErr_Occurred())
+        return XML_STATUS_ERROR;
+
     if (template_buffer[1] == 0) {
         for (i = 0; i < 256; i++)
             template_buffer[i] = i;

-- 
Repository URL: http://hg.python.org/cpython


More information about the Python-checkins mailing list