summaryrefslogtreecommitdiff
path: root/Lib/xml/sax/saxutils.py
diff options
context:
space:
mode:
authorMartin Panter <vadmium+py@gmail.com>2015-10-10 10:15:21 +0000
committerMartin Panter <vadmium+py@gmail.com>2015-10-10 10:15:21 +0000
commitb4c49a7b40ae96dbdc079b40b6c317bd2cbdeb55 (patch)
tree450aeb71ba9d9118732554bb4a7a4a22edc3734d /Lib/xml/sax/saxutils.py
parente013b9445b6f9caab1eb30b7785e3690d1bab4df (diff)
parentb98a5f90775e5f59662e452b3b31e0c07efa3d2c (diff)
downloadcpython-b4c49a7b40ae96dbdc079b40b6c317bd2cbdeb55.tar.gz
Issue #22413: Merge StringIO doc from 3.4 into 3.5
Diffstat (limited to 'Lib/xml/sax/saxutils.py')
-rw-r--r--Lib/xml/sax/saxutils.py7
1 files changed, 5 insertions, 2 deletions
diff --git a/Lib/xml/sax/saxutils.py b/Lib/xml/sax/saxutils.py
index 1d3d0ecc5f..a69c7f7621 100644
--- a/Lib/xml/sax/saxutils.py
+++ b/Lib/xml/sax/saxutils.py
@@ -345,11 +345,14 @@ def prepare_input_source(source, base=""):
elif hasattr(source, "read"):
f = source
source = xmlreader.InputSource()
- source.setByteStream(f)
+ if isinstance(f.read(0), str):
+ source.setCharacterStream(f)
+ else:
+ source.setByteStream(f)
if hasattr(f, "name") and isinstance(f.name, str):
source.setSystemId(f.name)
- if source.getByteStream() is None:
+ if source.getCharacterStream() is None and source.getByteStream() is None:
sysid = source.getSystemId()
basehead = os.path.dirname(os.path.normpath(base))
sysidfilename = os.path.join(basehead, sysid)