diff --git a/mitogen/parent.py b/mitogen/parent.py index e2c22110..d8485e15 100644 --- a/mitogen/parent.py +++ b/mitogen/parent.py @@ -339,7 +339,7 @@ def iter_read(fds, deadline=None): if not poller.readers: raise mitogen.core.StreamError( - 'EOF on stream; last 300 bytes received: %r' % + u'EOF on stream; last 300 bytes received: %r' % (b('').join(bits)[-300:].decode('latin1'),) ) raise mitogen.core.TimeoutError('read timed out') diff --git a/tests/parent_test.py b/tests/parent_test.py index 31c168e9..06eac97e 100644 --- a/tests/parent_test.py +++ b/tests/parent_test.py @@ -57,7 +57,8 @@ class StreamErrorTest(testlib.RouterMixin, testlib.TestCase): connect_timeout=3, ) ) - self.assertEquals(e.args[0], "EOF on stream; last 300 bytes received: ''") + prefix = "EOF on stream; last 300 bytes received: " + self.assertTrue(e.args[0].startswith(prefix)) def test_via_eof(self): # Verify FD leakage does not keep failed process open. @@ -69,7 +70,8 @@ class StreamErrorTest(testlib.RouterMixin, testlib.TestCase): connect_timeout=3, ) ) - self.assertTrue("EOF on stream; last 300 bytes received: ''" in e.args[0]) + s = "EOF on stream; last 300 bytes received: " + self.assertTrue(s in e.args[0]) def test_direct_enoent(self): e = self.assertRaises(mitogen.core.StreamError,