<div dir="ltr">I way to bypass this (pointed out by altendky) is to convert all the values of the dict to QVariant before sending it to the signal:<div><br></div>d = {k: v.toVariant() for k, v in message.object().items()}<br>doc = QJsonDocument(d)<br>self.messageReceived.emit(doc.object(), self) # that works fine<div><br></div><div>There's also another issue (which could be related or not to this):</div><div><br></div><div>d = {'a': 1}</div><div>j = PyQt5.QtCore.QJsonDocument(d)</div><div>o = j.object()</div><div>j = PyQt5.QtCore.QJsonDocument(o)</div><div><br></div><div>That fails:</div><div><br></div><div><div>TypeError: 'QJsonValue' object is not iterable</div><div><br></div><div>During handling of the above exception, another exception occurred:</div><div><br></div><div>Traceback (most recent call last):</div><div>  File "<stdin>", line 1, in <module></div><div>SystemError: <class 'PyQt5.QtCore.QJsonDocument'> returned a result with an error set</div><div><br></div><div>Here is a more readable example by altendky: <a href="https://gist.github.com/altendky/a64a7094524c68734de6fb59727d67b0">https://gist.github.com/altendky/a64a7094524c68734de6fb59727d67b0</a></div><div class="gmail_extra"><div><div class="gmail_signature"><br>--<br>Davi R. Tavares</div></div>
<br><div class="gmail_quote">On Fri, Jul 7, 2017 at 9:58 AM, Davi Ramos <span dir="ltr"><<a href="mailto:davirtavares@gmail.com" target="_blank">davirtavares@gmail.com</a>></span> wrote:<br><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left:1px solid rgb(204,204,204);padding-left:1ex"><div dir="ltr">Versions of PyQT tested: 5.8.2 and 5.9<br><br>Basically there is a signal on QWebChannelAbstractTransport called "messageReceived" and it's signature is as follow:<br><br>void messageReceived(const QJsonObject &message, QWebChannelAbstractTransport *transport)<br><br>According to PyQt documentation, QJsonObject is internally converted to "dict", but when I try to emit that signal passing a dict that was returned from QJsonDocument.object(), it fails:<br><br>message = QJsonDocument.fromJson(<wbr>messageData.encode("utf-8"), parser_error)<br>self.messageReceived.emit(<wbr>message.object(), self)<br><br>Traceback (most recent call last):<br>  File "main.py", line 54, in textMessageReceived<br>    self.messageReceived.emit(a, self)<br>TypeError: messageReceived(self, Dict[str, Union[QJsonValue, QJsonValue.Type, Iterable[QJsonValue], bool, int, float, str]], QWebChannelAbstractTransport).<wbr>emit(): argument 1 has unexpected type 'dict'<br>Aborted<div><br></div><div>I tried passing an empty dict {} and it worked (although it failed later cause of other reasons, but the signal was emitted).<br><br>A better context is provided here: <a href="https://pastebin.com/knJr26Rj" target="_blank">https://pastebin.com/knJr26Rj</a><br><br>--<br>Davi R. Tavares</div></div>
</blockquote></div><br></div></div></div>