From 3f767cfc962da7fd339fd605035e877141749381 Mon Sep 17 00:00:00 2001 From: Carlos Cordoba Date: Fri, 15 Sep 2017 13:57:04 -0500 Subject: [PATCH 1/2] IPython console: Don't show error when there's no kernel client available --- spyder/plugins/ipythonconsole.py | 5 ++++- spyder/widgets/ipythonconsole/shell.py | 5 ++++- 2 files changed, 8 insertions(+), 2 deletions(-) diff --git a/spyder/plugins/ipythonconsole.py b/spyder/plugins/ipythonconsole.py index 9169bb99bf4..e69a5e080a3 100644 --- a/spyder/plugins/ipythonconsole.py +++ b/spyder/plugins/ipythonconsole.py @@ -887,7 +887,10 @@ def run_script(self, filename, wdir, args, debug, post_mortem, line += "\"%s\"" % to_text_string(filename) if args: line += " %s" % norm(args) - self.execute_code(line, current_client, clear_variables) + try: + self.execute_code(line, current_client, clear_variables) + except AttributeError: + pass self.visibility_changed(True) self.raise_() else: diff --git a/spyder/widgets/ipythonconsole/shell.py b/spyder/widgets/ipythonconsole/shell.py index 0111614a21e..45045d9b3d3 100644 --- a/spyder/widgets/ipythonconsole/shell.py +++ b/spyder/widgets/ipythonconsole/shell.py @@ -290,7 +290,10 @@ def create_shortcuts(self): # --- To communicate with the kernel def silent_execute(self, code): """Execute code in the kernel without increasing the prompt""" - self.kernel_client.execute(to_text_string(code), silent=True) + try: + self.kernel_client.execute(to_text_string(code), silent=True) + except AttributeError: + pass def silent_exec_method(self, code): """Silently execute a kernel method and save its reply From ec630bce98e3308fa0249d7894cfea074e1fd0bf Mon Sep 17 00:00:00 2001 From: Carlos Cordoba Date: Fri, 15 Sep 2017 13:57:43 -0500 Subject: [PATCH 2/2] IPython console: Remove repeated application of to_text_string --- spyder/plugins/ipythonconsole.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/spyder/plugins/ipythonconsole.py b/spyder/plugins/ipythonconsole.py index e69a5e080a3..3b4676617d4 100644 --- a/spyder/plugins/ipythonconsole.py +++ b/spyder/plugins/ipythonconsole.py @@ -936,7 +936,7 @@ def execute_code(self, lines, current_client=True, clear_variables=False): sw.reset_namespace(warning=False, silent=True) elif current_client and clear_variables: sw.reset_namespace(warning=False, silent=True) - sw.execute(to_text_string(to_text_string(lines))) + sw.execute(to_text_string(lines)) self.activateWindow() self.get_current_client().get_control().setFocus()