mirror of
https://github.com/python/cpython.git
synced 2025-08-27 04:05:34 +00:00
Issue #2175: SAX parsers now support a character stream of InputSource object.
This commit is contained in:
parent
278ba2690c
commit
61de087f0f
7 changed files with 64 additions and 12 deletions
|
@ -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)
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue