diff --git a/src/python/grpcio_tests/tests/_runner.py b/src/python/grpcio_tests/tests/_runner.py index 39da0399b02..06f5d88fc3d 100644 --- a/src/python/grpcio_tests/tests/_runner.py +++ b/src/python/grpcio_tests/tests/_runner.py @@ -59,7 +59,7 @@ class CaptureFile(object): """Get all output from the redirected-to file if it exists.""" if self._into_file: self._into_file.seek(0) - return bytes(self._into_file.read()) + return bytes(self._into_file.read(), 'ascii') else: return bytes() diff --git a/tools/run_tests/python_utils/port_server.py b/tools/run_tests/python_utils/port_server.py index 256611c5aef..7c89929aab0 100755 --- a/tools/run_tests/python_utils/port_server.py +++ b/tools/run_tests/python_utils/port_server.py @@ -157,7 +157,7 @@ class Handler(BaseHTTPRequestHandler): self.end_headers() p = allocate_port(self) self.log_message('allocated port %d' % p) - self.wfile.write(bytes('%d' % p)) + self.wfile.write(('%d' % p).encode('utf8')) elif self.path[0:6] == '/drop/': self.send_response(200) self.send_header('Content-Type', 'text/plain') @@ -177,7 +177,7 @@ class Handler(BaseHTTPRequestHandler): self.send_response(200) self.send_header('Content-Type', 'text/plain') self.end_headers() - self.wfile.write(bytes('%d' % _MY_VERSION)) + self.wfile.write(bytes('%d' % _MY_VERSION, 'ascii')) elif self.path == '/dump': # yaml module is not installed on Macs and Windows machines by default # so we import it lazily (/dump action is only used for debugging) @@ -192,7 +192,7 @@ class Handler(BaseHTTPRequestHandler): 'in_use': dict((k, now - v) for k, v in in_use.items()) }) mu.release() - self.wfile.write(bytes(out)) + self.wfile.write(bytes(out, 'ascii')) elif self.path == '/quitquitquit': self.send_response(200) self.end_headers()