From 7e3493b74aa1cda85faa10c49e97046129b283f5 2017-02-03 12:18:03 From: Segev Finer Date: 2017-02-03 12:18:03 Subject: [PATCH] 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. --- diff --git a/IPython/lib/editorhooks.py b/IPython/lib/editorhooks.py index 2d263a0..905eabe 100644 --- a/IPython/lib/editorhooks.py +++ b/IPython/lib/editorhooks.py @@ -53,7 +53,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 862edc9..658276c 100644 --- a/IPython/lib/tests/test_editorhooks.py +++ b/IPython/lib/tests/test_editorhooks.py @@ -14,6 +14,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):