From a29fa80e04b87b6291a06f252f4f15acc910571c 2017-02-03 14:42:41 From: Thomas Kluyver Date: 2017-02-03 14:42:41 Subject: [PATCH] Backport PR #10239: IPython/lib/editorhooks.py: wait for process even if wait=False The wait parameter is meant to add a prompt before returning from the hook for editors that exit immediatly (fork/CreateProcess) but it accidently prevented waiting at all for the process when it was False. I think it was meant to be `not wait and proc.wait()` but we might as well wait for the process in the `wait=True` case anyhow. It's less confusing. It would be nice if this is backported to 5.x. --- diff --git a/IPython/lib/editorhooks.py b/IPython/lib/editorhooks.py index b76a89b..392557b 100644 --- a/IPython/lib/editorhooks.py +++ b/IPython/lib/editorhooks.py @@ -54,7 +54,7 @@ def install_editor(template, wait=False): if sys.platform.startswith('win'): cmd = shlex.split(cmd) proc = subprocess.Popen(cmd, shell=True) - if wait and proc.wait() != 0: + if proc.wait() != 0: raise TryNext() if wait: py3compat.input("Press Enter when done editing:") diff --git a/IPython/lib/tests/test_editorhooks.py b/IPython/lib/tests/test_editorhooks.py index 56085cf..1bedbce 100644 --- a/IPython/lib/tests/test_editorhooks.py +++ b/IPython/lib/tests/test_editorhooks.py @@ -18,6 +18,7 @@ def test_install_editor(): 'args': args, 'kwargs': kwargs, }) + return mock.MagicMock(**{'wait.return_value': 0}) editorhooks.install_editor('foo -l {line} -f {filename}', wait=False) with mock.patch('subprocess.Popen', fake_popen):