From e8d8f84e4ee2b5d06e7443adaed5da5dee613837 Mon Sep 17 00:00:00 2001 From: nikicc Date: Fri, 7 Oct 2016 11:44:01 +0200 Subject: [PATCH] OWPythonScript: Don't trigger reporting on errors --- Orange/widgets/data/owpythonscript.py | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/Orange/widgets/data/owpythonscript.py b/Orange/widgets/data/owpythonscript.py index fc1fe1d6bc1..34f31cc13a7 100644 --- a/Orange/widgets/data/owpythonscript.py +++ b/Orange/widgets/data/owpythonscript.py @@ -4,6 +4,7 @@ import keyword import itertools import unicodedata +from unittest.mock import patch from PyQt4 import QtGui, QtCore @@ -203,12 +204,11 @@ def push(self, line): self.history.insert(0, line) self.historyInd = 0 - saved = sys.stdout, sys.stderr - try: - sys.stdout, sys.stderr = self, self + # prevent console errors to trigger error reporting & patch stdout, stderr + with patch('sys.excepthook', sys.__excepthook__),\ + patch('sys.stdout', self),\ + patch('sys.stderr', self): return code.InteractiveConsole.push(self, line) - finally: - sys.stdout, sys.stderr = saved def setLine(self, line): cursor = QTextCursor(self.document())