From cef1dfe3684040823eacb15e234a529a56a355d7 Mon Sep 17 00:00:00 2001 From: Florian Bruhin Date: Tue, 16 Sep 2014 22:08:10 +0200 Subject: [PATCH] Remove exception handling code for qutescheme. The exceptions now get handled by @prevent_exceptions on the createRequest method of the NetworkManager, causing the exception handler to pop up properly. --- qutebrowser/network/qutescheme.py | 45 +++++++++++-------------------- 1 file changed, 16 insertions(+), 29 deletions(-) diff --git a/qutebrowser/network/qutescheme.py b/qutebrowser/network/qutescheme.py index 723f2e7a6..292939b1b 100644 --- a/qutebrowser/network/qutescheme.py +++ b/qutebrowser/network/qutescheme.py @@ -55,36 +55,23 @@ class QuteSchemeHandler(schemehandler.SchemeHandler): Return: A QNetworkReply. """ + path = request.url().path() + # An url like "qute:foo" is split as "scheme:path", not + # "scheme:host". + logutils.misc.debug("url: {}, path: {}".format( + request.url().toDisplayString(), path)) try: - path = request.url().path() - # An url like "qute:foo" is split as "scheme:path", not - # "scheme:host". - logutils.misc.debug("url: {}, path: {}".format( - request.url().toDisplayString(), path)) - try: - handler = getattr(QuteHandlers, path) - except AttributeError: - errorstr = "No handler found for {}!".format( - request.url().toDisplayString()) - return schemehandler.ErrorNetworkReply( - request, errorstr, QNetworkReply.ContentNotFoundError, - self.parent()) - else: - data = handler() - return schemehandler.SpecialNetworkReply( - request, data, 'text/html', self.parent()) - except: # pylint: disable=bare-except - # WORKAROUND - # Any exception raised in here will trigger a segfault. - # To prevent this, we return a page with the exception info. - # FIXME: We should report this to PyQt upstream. - text = "Exception in QuteSchemeHandler.createRequest:\n\n" - text += traceback.format_exc() - text += ("\nPlease use :report to report a bug and add the " - "information printed here by hand.") - data = text.encode('utf-8') - return schemehandler.SpecialNetworkReply( - request, data, 'text/plain', self.parent()) + handler = getattr(QuteHandlers, path) + except AttributeError: + errorstr = "No handler found for {}!".format( + request.url().toDisplayString()) + return schemehandler.ErrorNetworkReply( + request, errorstr, QNetworkReply.ContentNotFoundError, + self.parent()) + else: + data = handler() + return schemehandler.SpecialNetworkReply( + request, data, 'text/html', self.parent()) class QuteHandlers: