Issue #2175: SAX parsers now support a character stream of InputSource object.
diff --git a/Lib/test/test_sax.py b/Lib/test/test_sax.py
index c8d5b21..813dc2e 100644
--- a/Lib/test/test_sax.py
+++ b/Lib/test/test_sax.py
@@ -185,12 +185,24 @@
     def make_byte_stream(self):
         return BytesIO(b"This is a byte stream.")
 
+    def make_character_stream(self):
+        return StringIO("This is a character stream.")
+
     def checkContent(self, stream, content):
         self.assertIsNotNone(stream)
         self.assertEqual(stream.read(), content)
         stream.close()
 
 
+    def test_character_stream(self):
+        # If the source is an InputSource with a character stream, use it.
+        src = InputSource(self.file)
+        src.setCharacterStream(self.make_character_stream())
+        prep = prepare_input_source(src)
+        self.assertIsNone(prep.getByteStream())
+        self.checkContent(prep.getCharacterStream(),
+                          "This is a character stream.")
+
     def test_byte_stream(self):
         # If the source is an InputSource that does not have a character
         # stream but does have a byte stream, use the byte stream.
@@ -225,6 +237,14 @@
         self.checkContent(prep.getByteStream(),
                           b"This is a byte stream.")
 
+    def test_text_file(self):
+        # If the source is a text file-like object, use it as a character
+        # stream.
+        prep = prepare_input_source(self.make_character_stream())
+        self.assertIsNone(prep.getByteStream())
+        self.checkContent(prep.getCharacterStream(),
+                          "This is a character stream.")
+
 
 # ===== XMLGenerator
 
@@ -904,6 +924,19 @@
 
         self.assertEqual(result.getvalue(), xml_test_out)
 
+    def test_expat_inpsource_character_stream(self):
+        parser = create_parser()
+        result = BytesIO()
+        xmlgen = XMLGenerator(result)
+
+        parser.setContentHandler(xmlgen)
+        inpsrc = InputSource()
+        with open(TEST_XMLFILE, 'rt', encoding='iso-8859-1') as f:
+            inpsrc.setCharacterStream(f)
+            parser.parse(inpsrc)
+
+        self.assertEqual(result.getvalue(), xml_test_out)
+
     # ===== IncrementalParser support
 
     def test_expat_incremental(self):