launchpad-reviewers team mailing list archive
-
launchpad-reviewers team
-
Mailing list archive
-
Message #25680
[Merge] ~cjwatson/launchpad:py3-command-spawner into launchpad:master
Colin Watson has proposed merging ~cjwatson/launchpad:py3-command-spawner into launchpad:master.
Commit message:
Fix CommandSpawner on Python 3
Requested reviews:
Launchpad code reviewers (launchpad-reviewers)
For more details, see:
https://code.launchpad.net/~cjwatson/launchpad/+git/launchpad/+merge/393814
We only ever use this for logging textual output, so just unconditionally treat process output as text rather than bothering to make it optional.
--
Your team Launchpad code reviewers is requested to review the proposed merge of ~cjwatson/launchpad:py3-command-spawner into launchpad:master.
diff --git a/lib/lp/services/command_spawner.py b/lib/lp/services/command_spawner.py
index 988110c..98bcc1d 100644
--- a/lib/lp/services/command_spawner.py
+++ b/lib/lp/services/command_spawner.py
@@ -158,7 +158,7 @@ class CommandSpawner:
"""Spawn a sub-process for `command`. Overridable in tests."""
return subprocess.Popen(
command, stdout=subprocess.PIPE, stderr=subprocess.PIPE,
- close_fds=True)
+ close_fds=True, universal_newlines=True)
def _handle(self, process, event, *args):
"""If we have a handler for `event` on `process`, call it."""
diff --git a/lib/lp/services/tests/test_command_spawner.py b/lib/lp/services/tests/test_command_spawner.py
index 12ccb7a..c7cc06c 100644
--- a/lib/lp/services/tests/test_command_spawner.py
+++ b/lib/lp/services/tests/test_command_spawner.py
@@ -97,7 +97,7 @@ class TestCommandSpawner(TestCase):
def test_start_adds_a_process(self):
spawner, process = self._makeSpawnerAndProcess()
spawner.start("/bin/true")
- self.assertEqual([process], spawner.running_processes.keys())
+ self.assertEqual([process], list(spawner.running_processes))
def test_start_runs_its_command(self):
spawner, process = self._makeSpawnerAndProcess()