Details
-
Bug
-
Resolution: Invalid
-
Not Evaluated
-
None
-
1.2.0
-
None
-
Ubuntu 14.04 on x86_64
Description
The QtCore.QFile class' read method returns a QByteArray, which xml.sax.parse can't handle right away in Python 3.4.0. It works in Python 2.7.6. Here is a testcase:
import PySide2 import xml.sax, xml.sax.handler buf = PySide2.QtCore.QByteArray(b"<foo/>") xml.sax.parseString(buf, xml.sax.handler.ContentHandler())
Here's the error I get in Python 3.4.0:
Traceback (most recent call last): File "qbytearray.py", line 6, in <module> xml.sax.parseString(buf, xml.sax.handler.ContentHandler()) File "/usr/lib/python3.4/xml/sax/__init__.py", line 45, in parseString inpsrc.setByteStream(BytesIO(string)) TypeError: 'PySide.QtCore.QByteArray' does not support the buffer interface
The same error occurs with xml.sax.parse(fp, handler) when fp is of the QtCore.QFile type.
I have a workaround that converts the QByteArray to a bytes type before passing it to the xml parser.