[PyQt] QNetworkAccessManager.sslErrors in PyQt 5.2.1

Glenn Ramsey gr at componic.co.nz
Wed Jun 11 10:32:30 BST 2014


On 11/06/14 20:43, Florian Bruhin wrote:
> * Glenn Ramsey <gr at componic.co.nz> [2014-06-11 20:17:34 +1200]:
>> I am trying to implement a fix for loading pages via https in QtWebKit as
>> described in this thread:
>>
>> http://www.mail-archive.com/pyqt%40riverbankcomputing.com/msg21139.html
>>
>> It suggests to do this:
>>
>>          self.connect (self.browserWindow.page().networkAccessManager(),
>> SIGNAL("sslErrors (QNetworkReply *, const QList<QSslError> &)"),
>> self.sslErrorHandler)
>>
>>      def sslErrorHandler(self, reply, errorList):
>>          reply.ignoreSslErrors()
>>          print ("SSL error ignored")
>>
>>
>> When I try it in PyQt5 (5.2.1)
>>
>> self._webView.page().networkAccessManager().sslErrors.connect(self.handleSslErrors)
>>
>> I get
>>
>> AttributeError: 'QNetworkAccessManager' object has no attribute 'sslErrors'
>>
>> Is this a bug, or am I doing it wrong?
>
> Works just fine here:
>
>      >>> from PyQt5.QtCore import QT_VERSION_STR
>      >>> from PyQt5.QtWidgets import QApplication
>      >>> from PyQt5.QtNetwork import QNetworkAccessManager
>      >>> QT_VERSION_STR
>      '5.2.0'
>      >>> app = QApplication([])
>      >>> nam = QNetworkAccessManager()
>      >>> nam.sslErrors
>      <bound signal sslErrors of QNetworkAccessManager object at 0x00000000030A7828>
>
> Same in 5.3.0 as well.
>
> I wonder if you somehow got a Qt build without SSL support?
>
> The eric helpviewer by Detlev Offenbach (who is also on this ML, I
> think) does in fact handle this explicitely, basically like this:
>
>      try:
>          from PyQt4.QtNetwork import QSslSocket
>          ...
>          SSL_AVAILABLE = True
>      except ImportError:
>          SSL_AVAILABLE = False
>
>      ...
>
>      if SSL_AVAILABLE:
>          ...
>          self.sslErrors.connect(self.__sslErrorHandler.sslErrorsReplySlot)
>
>
> Florian

Thanks Florian, that was the problem. My Qt was built without SSL support.

Glenn



More information about the PyQt mailing list