[pyzo] 54/68: Prevent Pyzo abort on Python exception. Fixes #437

Ghislain Vaillant ghisvail-guest at moszumanska.debian.org
Wed Sep 28 09:47:14 UTC 2016


This is an automated email from the git hooks/post-receive script.

ghisvail-guest pushed a commit to branch debian/master
in repository pyzo.

commit 761c6bf80b7ddbcb14930d3e58ff5b327d031ec9
Author: Almar Klein <almar.klein at gmail.com>
Date:   Mon Sep 26 10:54:26 2016 +0200

    Prevent Pyzo abort on Python exception. Fixes #437
---
 pyzo/__init__.py | 14 ++++++++++++++
 1 file changed, 14 insertions(+)

diff --git a/pyzo/__init__.py b/pyzo/__init__.py
index 1f84215..cde5bc5 100644
--- a/pyzo/__init__.py
+++ b/pyzo/__init__.py
@@ -46,6 +46,7 @@ __version__ = '4.2.1'
 import os
 import sys
 import locale
+import traceback
 
 # Check Python version
 if sys.version < '3':
@@ -103,6 +104,19 @@ class MyApp(QtWidgets.QApplication):
 if not sys.platform.startswith('darwin'):
     MyApp = QtWidgets.QApplication
 
+## Install excepthook
+# In PyQt5 exceptions in Python will cuase an abort
+# http://pyqt.sourceforge.net/Docs/PyQt5/incompatibilities.html
+
+def pyzo_excepthook(type, value, tb):
+    out = 'Uncaught Python exception: ' + str(value) + '\n'
+    out += ''.join(traceback.format_list(traceback.extract_tb(tb)))
+    out += '\n'
+    sys.stderr.write(out)
+
+sys.excepthook = pyzo_excepthook
+
+
 ## Define some functions
 
 

-- 
Alioth's /usr/local/bin/git-commit-notice on /srv/git.debian.org/git/debian-science/packages/pyzo.git



More information about the debian-science-commits mailing list