diff --git a/qubes/tests/extra.py b/qubes/tests/extra.py index a1e0f03e..91a26495 100644 --- a/qubes/tests/extra.py +++ b/qubes/tests/extra.py @@ -42,6 +42,8 @@ class ProcessWrapper(object): return setattr(self._proc, key, value) def communicate(self, input=None): + if self._proc.stdin is not None and input is None: + input = b'' return self._loop.run_until_complete(self._proc.communicate(input)) def wait(self): diff --git a/qubes/tests/vm/qubesvm.py b/qubes/tests/vm/qubesvm.py index 2f27cb13..6f0a8319 100644 --- a/qubes/tests/vm/qubesvm.py +++ b/qubes/tests/vm/qubesvm.py @@ -2017,7 +2017,7 @@ class TC_90_QubesVM(QubesVMTestsMixin, qubes.tests.QubesTestCase): stdout=subprocess.PIPE, stderr=subprocess.PIPE, stdin=subprocess.PIPE) - communicate_mock.assert_called_once_with(input=None) + communicate_mock.assert_called_once_with(input=b'') self.assertEqual(value, (b'stdout', b'stderr')) func_mock.reset_mock() @@ -2045,7 +2045,7 @@ class TC_90_QubesVM(QubesVMTestsMixin, qubes.tests.QubesTestCase): stdout=subprocess.PIPE, stderr=subprocess.PIPE, stdin=subprocess.PIPE) - communicate_mock.assert_called_once_with(input=None) + communicate_mock.assert_called_once_with(input=b'') self.assertEqual(exc.exception.returncode, 1) self.assertEqual(exc.exception.output, b'stdout') self.assertEqual(exc.exception.stderr, b'stderr') diff --git a/qubes/vm/qubesvm.py b/qubes/vm/qubesvm.py index 3ed3aed1..395614f5 100644 --- a/qubes/vm/qubesvm.py +++ b/qubes/vm/qubesvm.py @@ -1435,6 +1435,9 @@ class QubesVM(qubes.vm.mix.net.NetVMMixin, qubes.vm.BaseVM): kwargs.setdefault('stdin', subprocess.PIPE) kwargs.setdefault('stdout', subprocess.PIPE) kwargs.setdefault('stderr', subprocess.PIPE) + if kwargs['stdin'] == subprocess.PIPE and input is None: + # workaround for https://bugs.python.org/issue39744 + input = b'' p = yield from self.run_service(*args, **kwargs) # this one is actually a tuple, but there is no need to unpack it @@ -1471,6 +1474,9 @@ class QubesVM(qubes.vm.mix.net.NetVMMixin, qubes.vm.BaseVM): kwargs.setdefault('stdin', subprocess.PIPE) kwargs.setdefault('stdout', subprocess.PIPE) kwargs.setdefault('stderr', subprocess.PIPE) + if kwargs['stdin'] == subprocess.PIPE and input is None: + # workaround for https://bugs.python.org/issue39744 + input = b'' p = yield from self.run(*args, **kwargs) stdouterr = yield from p.communicate(input=input)