From 016f7549b865644189dbb941764a39ec9648d2e8 Mon Sep 17 00:00:00 2001 From: Adam Cogdell Date: Fri, 11 Aug 2023 14:00:59 -0700 Subject: [PATCH] Use pybind11_protobuf when passing Fingerprints. PiperOrigin-RevId: 556081074 --- pybind11_protobuf/proto_caster_impl.h | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/pybind11_protobuf/proto_caster_impl.h b/pybind11_protobuf/proto_caster_impl.h index 636828a..6ca050c 100644 --- a/pybind11_protobuf/proto_caster_impl.h +++ b/pybind11_protobuf/proto_caster_impl.h @@ -40,11 +40,13 @@ struct proto_caster_load_impl { // load converts from Python -> C++ bool load(pybind11::handle src, bool convert) { + LOG(ERROR) << 1; // When given a none, treat it as a nullptr. if (src.is_none()) { value = nullptr; return true; } + LOG(ERROR) << 1; // NOTE: We might need to know whether the proto has extensions that // are python-only. @@ -52,8 +54,10 @@ struct proto_caster_load_impl { // from the object. const ::google::protobuf::Message *message = pybind11_protobuf::PyProtoGetCppMessagePointer(src); + LOG(ERROR) << 1; if (message && message->GetReflection() == ProtoType::default_instance().GetReflection()) { + LOG(ERROR) << 1; // If the capability were available, then we could probe PyProto_API and // allow c++ mutability based on the python reference count. value = static_cast(message); @@ -62,13 +66,17 @@ struct proto_caster_load_impl { // The incoming object is not a compatible fast_cpp_proto, so check whether // it is otherwise compatible, then serialize it and deserialize into a + LOG(ERROR) << 1; // native C++ proto type. if (!pybind11_protobuf::PyProtoIsCompatible(src, ProtoType::GetDescriptor())) { + LOG(ERROR) << 1; return false; } + LOG(ERROR) << 1; owned = std::unique_ptr(new ProtoType()); value = owned.get(); + LOG(ERROR) << 1; return pybind11_protobuf::PyProtoCopyToCProto(src, owned.get()); }