Issue #17606: Fixed support of encoded byte strings in the XMLGenerator
characters() and ignorableWhitespace() methods.  Original patch by Sebastian
Ortiz Vasquez.
diff --git a/Lib/xml/sax/saxutils.py b/Lib/xml/sax/saxutils.py
index 0798ecd..74de9b0 100644
--- a/Lib/xml/sax/saxutils.py
+++ b/Lib/xml/sax/saxutils.py
@@ -209,11 +209,15 @@
     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):