Issue #17606: Fixed support of encoded byte strings in the XMLGenerator

characters() and ignorableWhitespace() methods.  Original patch by Sebastian
Ortiz Vasquez.
This commit is contained in:
Serhiy Storchaka 2013-05-12 17:31:59 +03:00
commit 3068aed92b
4 changed files with 27 additions and 0 deletions

View file

@ -209,11 +209,15 @@ class XMLGenerator(handler.ContentHandler):
def characters(self, content):
if content:
self._finish_pending_start_element()
if not isinstance(content, str):
content = str(content, self._encoding)
self._write(escape(content))
def ignorableWhitespace(self, content):
if content:
self._finish_pending_start_element()
if not isinstance(content, str):
content = str(content, self._encoding)
self._write(content)
def processingInstruction(self, target, data):