Skip to content

Commit 4224a3f

Browse files
committed
python: Fix SAX driver with character streams
This apparently broke with Python 3.5 which introduced character streams. Fixes #790.
1 parent da9f892 commit 4224a3f

File tree

1 file changed

+4
-1
lines changed

1 file changed

+4
-1
lines changed

python/drv_libxml2.py

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -146,7 +146,10 @@ def parse(self, source):
146146
reader = libxml2.newTextReaderFilename(source)
147147
else:
148148
source = saxutils.prepare_input_source(source)
149-
input = libxml2.inputBuffer(source.getByteStream())
149+
stream = source.getCharacterStream()
150+
if stream is None:
151+
stream = source.getByteStream()
152+
input = libxml2.inputBuffer(stream)
150153
reader = input.newTextReader(source.getSystemId())
151154
reader.SetErrorHandler(self._errorHandler,None)
152155
# configure reader

0 commit comments

Comments
 (0)