From 2b2505683f9dd91b6f2f8aeb1ac0798c975a53d6 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Tom=C3=A1s=20Touceda?= Date: Fri, 19 Jul 2013 11:35:27 -0300 Subject: Workaround segfault when emitting a signal with a None parameter Also, support a response from requests be None in certain places. --- src/leap/crypto/srpregister.py | 14 ++++++++++---- src/leap/gui/wizard.py | 4 ++-- src/leap/util/request_helpers.py | 2 +- 3 files changed, 13 insertions(+), 7 deletions(-) diff --git a/src/leap/crypto/srpregister.py b/src/leap/crypto/srpregister.py index 24f73504..de1978b5 100644 --- a/src/leap/crypto/srpregister.py +++ b/src/leap/crypto/srpregister.py @@ -124,7 +124,12 @@ class SRPRegister(QtCore.QObject): logger.debug('Post to uri: %s' % uri) logger.debug("Will try to register user = %s" % (username,)) - ok = None + ok = False + # This should be None, but we don't like when PySide segfaults, + # so it something else. + # To reproduce it, just do: + # self.registration_finished.emit(False, None) + req = [] try: req = self._session.post(uri, data=user_data, @@ -132,12 +137,13 @@ class SRPRegister(QtCore.QObject): verify=self._provider_config. get_ca_cert_path()) - except requests.exceptions.SSLError as exc: - logger.error("SSLError: %s" % exc.message) - req = None + except (requests.exceptions.SSLError, + requests.exceptions.ConnectionError) as exc: + logger.error(exc.message) ok = False else: ok = req.ok + self.registration_finished.emit(ok, req) return ok diff --git a/src/leap/gui/wizard.py b/src/leap/gui/wizard.py index 5333edeb..2b48fc81 100644 --- a/src/leap/gui/wizard.py +++ b/src/leap/gui/wizard.py @@ -309,8 +309,8 @@ class Wizard(QtGui.QWizard): error_msg = json_content.get("errors").get("login")[0] if not error_msg.istitle(): error_msg = "%s %s" % (old_username, error_msg) - except: - logger.error("Unknown error: %r" % (req.content,)) + except Exception as e: + logger.error("Unknown error: %r" % (e,)) self._set_register_status(error_msg, error=True) self.ui.btnRegister.setEnabled(True) diff --git a/src/leap/util/request_helpers.py b/src/leap/util/request_helpers.py index 350abfbd..74aaa06b 100644 --- a/src/leap/util/request_helpers.py +++ b/src/leap/util/request_helpers.py @@ -41,7 +41,7 @@ def get_content(request): contents = "" mtime = None - if request.content and request.json: + if request and request.content and request.json: if callable(request.json): contents = json.dumps(request.json()) else: -- cgit v1.2.3 From 36e1d76d8539135c3424c0e6e82ad26c8ec2529d Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Tom=C3=A1s=20Touceda?= Date: Fri, 19 Jul 2013 11:36:07 -0300 Subject: Fix raise calls --- src/leap/gui/mainwindow.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/leap/gui/mainwindow.py b/src/leap/gui/mainwindow.py index 6ee8b028..6fe3e72d 100644 --- a/src/leap/gui/mainwindow.py +++ b/src/leap/gui/mainwindow.py @@ -321,7 +321,7 @@ class MainWindow(QtGui.QMainWindow): # Refer to http://www.themacaque.com/?p=1067 for funny details. self._wizard.show() if IS_MAC: - self._wizard._raise() + self._wizard.raise_() self._wizard.finished.connect(self._wizard_finished) def _wizard_finished(self): @@ -1304,7 +1304,7 @@ class MainWindow(QtGui.QMainWindow): self.setWindowFlags(self.windowFlags() & ~TOPFLAG) self.show() if IS_MAC: - self._raise() + self.raise_() def _cleanup_pidfiles(self): """ -- cgit v1.2.3 From 0e92595da3844516d9a67bbbbd88c2957f0a29bc Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Tom=C3=A1s=20Touceda?= Date: Fri, 19 Jul 2013 11:42:35 -0300 Subject: Add changes file --- changes/bug_segfault_signal | 2 ++ 1 file changed, 2 insertions(+) create mode 100644 changes/bug_segfault_signal diff --git a/changes/bug_segfault_signal b/changes/bug_segfault_signal new file mode 100644 index 00000000..39d9c910 --- /dev/null +++ b/changes/bug_segfault_signal @@ -0,0 +1,2 @@ + o Workaround a segmentation fault when emitting a signal with its + last parameter being None. Fixes #3083. \ No newline at end of file -- cgit v1.2.3