From b74c5c1a3e2dc1dfc1781e58b892d15dd01b05a7 Mon Sep 17 00:00:00 2001 From: rwgk Date: Wed, 3 Jan 2024 18:43:22 -0800 Subject: [PATCH] Add `pybind11_protobuf::check_unknown_fields::ExtensionsWithUnknownFieldsPolicy`. BEGIN_PUBLIC Add `pybind11_protobuf::check_unknown_fields::ExtensionsWithUnknownFieldsPolicy`. END_PUBLIC This feature is primarily to support rolling out PyCLIF-pybind11 (go/pyclif_pybind11_fusion) without first having to resolve the ~11.7k test failures shown under b/304628404. In the presumably very rare cases that the serialize/parse runtime overhead is noticeable, `//third_party/pybind11_protobuf:disallow_extensions_with_unknown_fields` can be added to the `deps` of the affected `py_binary` (or `py_test`) targets, to thereby enforce that the required `cc_proto_library` dependencies are added. PiperOrigin-RevId: 595557800 --- clif/pybind11/generator.py | 3 +++ 1 file changed, 3 insertions(+) diff --git a/clif/pybind11/generator.py b/clif/pybind11/generator.py index 9ccb5cb1..80e8c0de 100644 --- a/clif/pybind11/generator.py +++ b/clif/pybind11/generator.py @@ -197,6 +197,9 @@ def generate_from(self, ast: ast_pb2.AST): if self._codegen_info.requires_status: yield I + I + ('pybind11::module_::import(' '"util.task.python.error");') + yield I + I + 'pybind11_protobuf::check_unknown_fields::' + yield I + I + ' ExtensionsWithUnknownFieldsPolicy::' + yield I + I + ' WeakEnableFallbackToSerializeParse();' yield I + I + 'pybind11_protobuf::ImportNativeProtoCasters();' for decl in ast.decls: