From 8b7dabe1a25a4758e89b5dc23c17585ebda141c3 Mon Sep 17 00:00:00 2001 From: Joshua Haberman <jhaberman@gmail.com> Date: Tue, 10 Nov 2020 20:44:27 -0800 Subject: [PATCH] Use format() instead of string interpolation, for old Python versions. --- benchmarks/BUILD | 2 ++ benchmarks/gen_protobuf_binary_cc.py | 8 ++++---- benchmarks/gen_upb_binary_c.py | 8 ++++---- 3 files changed, 10 insertions(+), 8 deletions(-) diff --git a/benchmarks/BUILD b/benchmarks/BUILD index 246e96764a..641e1389f1 100644 --- a/benchmarks/BUILD +++ b/benchmarks/BUILD @@ -84,11 +84,13 @@ py_binary( py_binary( name = "gen_upb_binary_c", srcs = ["gen_upb_binary_c.py"], + python_version = "PY3", ) py_binary( name = "gen_protobuf_binary_cc", srcs = ["gen_protobuf_binary_cc.py"], + python_version = "PY3", ) genrule( diff --git a/benchmarks/gen_protobuf_binary_cc.py b/benchmarks/gen_protobuf_binary_cc.py index 181cafcde8..787e391547 100644 --- a/benchmarks/gen_protobuf_binary_cc.py +++ b/benchmarks/gen_protobuf_binary_cc.py @@ -11,22 +11,22 @@ if m: msg_basename = m.group(1) count = int(m.group(2)) -print(f''' +print(''' #include "{include}" char buf[1]; int main() {{ -''') +'''.format(include=include)) def RefMessage(name): - print(f''' + print(''' {{ {name} proto; proto.ParseFromArray(buf, 0); proto.SerializePartialToArray(&buf[0], 0); }} - ''') + '''.format(name=name)) RefMessage(msg_basename) diff --git a/benchmarks/gen_upb_binary_c.py b/benchmarks/gen_upb_binary_c.py index 430d8c45c9..4df8fd7327 100644 --- a/benchmarks/gen_upb_binary_c.py +++ b/benchmarks/gen_upb_binary_c.py @@ -11,7 +11,7 @@ if m: msg_basename = m.group(1) count = int(m.group(2)) -print(f''' +print(''' #include "{include}" char buf[1]; @@ -19,15 +19,15 @@ char buf[1]; int main() {{ upb_arena *arena = upb_arena_new(); size_t size; -''') +'''.format(include=include)) def RefMessage(name): - print(f''' + print(''' {{ {name} *proto = {name}_parse(buf, 1, arena); {name}_serialize(proto, arena, &size); }} - ''') + '''.format(name=name)) RefMessage(msg_basename)