Commit 9004feda authored by Guido van Rossum's avatar Guido van Rossum

Add new API: parseFragment(s, end=0) -- parses a fragment of source

code.

Add the exception raised by Expat to the module, under the name
XMLParseError (which was the name used by the test suite).
parent 4e5b4b41
......@@ -132,11 +132,14 @@ class XMLParser:
sys.stderr.write("Can't set expat handler %s\n" % name)
def createParser(self, encoding=None):
global XMLParseError
try:
from Products.ParsedXML.Expat import pyexpat
XMLParseError = pyexpat.ExpatError
return pyexpat.ParserCreate(encoding, ' ')
except ImportError:
from xml.parsers import expat
XMLParseError = expat.ExpatError
return expat.ParserCreate(encoding, ' ')
def parseFile(self, filename):
......@@ -151,3 +154,6 @@ class XMLParser:
def parseStream(self, stream):
self.parser.ParseFile(stream)
def parseFragment(self, s, end=0):
self.parser.Parse(s, end)
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment