From 324672e6bb0fe8e66cd01e3936f635e53fc1bdc5 Mon Sep 17 00:00:00 2001 From: pybind11_protobuf authors Date: Mon, 13 Jan 2025 19:34:16 -0800 Subject: [PATCH] Prepare code for breaking change in Protobuf C++ API. Protobuf 6.30.0 will change the return types of Descriptor::name() and other methods to absl::string_view. This makes the code work both before and after such a change. PiperOrigin-RevId: 715199813 --- pybind11_protobuf/proto_cast_util.cc | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/pybind11_protobuf/proto_cast_util.cc b/pybind11_protobuf/proto_cast_util.cc index 11a7704..a098bcb 100644 --- a/pybind11_protobuf/proto_cast_util.cc +++ b/pybind11_protobuf/proto_cast_util.cc @@ -59,8 +59,8 @@ namespace { // Resolves the class name of a descriptor via d->containing_type() py::object ResolveDescriptor(py::object p, const Descriptor* d) { return d->containing_type() ? ResolveDescriptor(p, d->containing_type()) - .attr(py::str(d->name())) - : p.attr(py::str(d->name())); + .attr(py::str(std::string_view(d->name()))) + : p.attr(py::str(std::string_view(d->name()))); } // Returns true if an exception is an import error.