[Python-checkins] cpython: Issue #18227: pyexpat now uses a static XML_Memory_Handling_Suite. cElementTree

christian.heimes python-checkins at python.org
Sun Jul 7 17:35:20 CEST 2013


http://hg.python.org/cpython/rev/7f17c67b5bf6
changeset:   84500:7f17c67b5bf6
user:        Christian Heimes <christian at cheimes.de>
date:        Sun Jul 07 17:35:11 2013 +0200
summary:
  Issue #18227: pyexpat now uses a static XML_Memory_Handling_Suite. cElementTree uses the same approach since at least Python 2.6

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


diff --git a/Modules/pyexpat.c b/Modules/pyexpat.c
--- a/Modules/pyexpat.c
+++ b/Modules/pyexpat.c
@@ -10,6 +10,9 @@
 
 #define FIX_TRACE
 
+static XML_Memory_Handling_Suite ExpatMemoryHandler = {
+    PyObject_Malloc, PyObject_Realloc, PyObject_Free};
+
 enum HandlerTypes {
     StartElement,
     EndElement,
@@ -1177,12 +1180,9 @@
     self->in_callback = 0;
     self->ns_prefixes = 0;
     self->handlers = NULL;
-    if (namespace_separator != NULL) {
-        self->itself = XML_ParserCreateNS(encoding, *namespace_separator);
-    }
-    else {
-        self->itself = XML_ParserCreate(encoding);
-    }
+    /* namespace_separator is either NULL or contains one char + \0 */
+    self->itself = XML_ParserCreate_MM(encoding, &ExpatMemoryHandler,
+                                       namespace_separator);
 #if ((XML_MAJOR_VERSION >= 2) && (XML_MINOR_VERSION >= 1)) || defined(XML_HAS_SET_HASH_SALT)
     /* This feature was added upstream in libexpat 2.1.0.  Our expat copy
      * has a backport of this feature where we also define XML_HAS_SET_HASH_SALT

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


More information about the Python-checkins mailing list