Make scripts/docs/dot_converter.py Python 3 compatible so //site can be built with Bazel 0.27 without --force_host_python=PY2.
Python 3 changed the type of subprocess#communicate to accept bytes, not str. Change everything else accordingly.
```
$ bazel build //site
# ...
Traceback (most recent call last):
File "/usr/local/google/home/jingwen/.cache/bazel/_bazel_jingwen/c512c74f287f8aa09b4f3666e26c2b04/sandbox/linux-sandbox/777/execroot/io_bazel/bazel-out/host/bin/scripts/docs/generate_dot_graphs.runfiles/io_bazel/scripts/docs/generate_dot_graphs.py", line 23, in <module>
converter.convert()
File "/usr/local/google/home/jingwen/.cache/bazel/_bazel_jingwen/c512c74f287f8aa09b4f3666e26c2b04/sandbox/linux-sandbox/777/execroot/io_bazel/bazel-out/host/bin/scripts/docs/generate_dot_graphs.runfiles/io_bazel/scripts/docs/dot_converter.py", line 42, in convert
output = dot.communicate(graph)[0].decode()
File "/usr/lib/python3.6/subprocess.py", line 843, in communicate
stdout, stderr = self._communicate(input, endtime, timeout)
File "/usr/lib/python3.6/subprocess.py", line 1499, in _communicate
input_view = memoryview(self._input)
TypeError: memoryview: a bytes-like object is required, not 'str'
```
RELNOTES: None.
PiperOrigin-RevId: 254177933
diff --git a/scripts/docs/dot_converter.py b/scripts/docs/dot_converter.py
index c65a15e..75addbf 100644
--- a/scripts/docs/dot_converter.py
+++ b/scripts/docs/dot_converter.py
@@ -28,7 +28,7 @@
def convert(self):
collect = False
- graph = ""
+ graph = b""
block_num = 0
for line in fileinput.input():
@@ -39,18 +39,18 @@
dot = subprocess.Popen(
self.dot_command,
stdin=subprocess.PIPE, stdout=subprocess.PIPE, env=self.dot_env)
- output = dot.communicate(graph)[0]
+ output = dot.communicate(graph)[0].decode()
if dot.returncode == 0:
# cut the first few lines (svg header + comments)
sys.stdout.write(output.split("\n", 6)[6])
else:
sys.stderr.write("inlining block %d failed.\n" % (block_num + 1))
collect = False
- graph = ""
+ graph = b""
block_num += 1
continue
if collect:
- graph += line
+ graph += str.encode(line)
else:
sys.stdout.write(line)