diff options
Diffstat (limited to 'xmlparser.py')
-rw-r--r-- | xmlparser.py | 5 |
1 files changed, 5 insertions, 0 deletions
diff --git a/xmlparser.py b/xmlparser.py index 593bcbe..aafa693 100644 --- a/xmlparser.py +++ b/xmlparser.py @@ -74,6 +74,11 @@ class XMLParser(object): self.parseStream(open(filename)) def parseString(self, s): + if isinstance(s, unicode): + # Expat cannot deal with unicode strings, only with + # encoded ones. Also, its range of encodings is rather + # limited, UTF-8 is the safest bet here. + s = s.encode('utf-8') self.parser.Parse(s, 1) def parseURL(self, url): |