[IronPython] fix for fepy's pyexpat.py

Fredrik Lundh fredrik at pythonware.com
Sun Nov 19 11:06:38 CET 2006


pyexpat.py's "parse" method treats all calls as "final", which means that it
simply doesn't work for files larger than a few kilobytes (32k for ET, 16k for
minidom).  here's a workaround:

> diff -u ironexpat.bak ironexpat.py
--- pyexpat.bak       Sun Nov 19 11:01:04 2006
+++ pyexpat.py        Sun Nov 19 11:01:21 2006
@@ -38,6 +38,7 @@

     __slots__ = [
         # Internal
+        "_data",
         "_separator",
         "_reader",
         "_ns_stack",
@@ -79,13 +80,17 @@
     intern = {}

     def __init__(self, separator):
+        self._data = []
         self._separator = separator
         self._ns_stack = []
         self.ordered_attributes = False
         self.namespace_prefixes = False

     def Parse(self, data, isfinal=False):
-        if data:
+        self._data.append(data)
+        if isfinal:
+            data = "".join(self._data)
+            self._data = None
             self._parse(data)

     def _qname(self):

cheers /F



More information about the Ironpython-users mailing list