[PyQt] QNetworkAccessManager.sslErrors in PyQt 5.2.1

Florian Bruhin me at the-compiler.org
Wed Jun 11 09:43:26 BST 2014


* 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

-- 
http://www.the-compiler.org | me at the-compiler.org (Mail/XMPP)
             GPG 0xFD55A072 | http://the-compiler.org/pubkey.asc
         I love long mails! | http://email.is-not-s.ms/
-------------- next part --------------
A non-text attachment was scrubbed...
Name: not available
Type: application/pgp-signature
Size: 836 bytes
Desc: not available
URL: <http://www.riverbankcomputing.com/pipermail/pyqt/attachments/20140611/c302dc66/attachment.sig>


More information about the PyQt mailing list