From 5a23b81517626fad736ecc281f336e8dc20ab1f5 Mon Sep 17 00:00:00 2001 From: pybind11_protobuf authors Date: Mon, 18 May 2026 23:38:00 -0700 Subject: [PATCH] Automated Code Change PiperOrigin-RevId: 917636306 --- pybind11_protobuf/check_unknown_fields.cc | 4 ++-- pybind11_protobuf/proto_cast_util.cc | 9 +++++---- 2 files changed, 7 insertions(+), 6 deletions(-) diff --git a/pybind11_protobuf/check_unknown_fields.cc b/pybind11_protobuf/check_unknown_fields.cc index dca0e25..4307999 100644 --- a/pybind11_protobuf/check_unknown_fields.cc +++ b/pybind11_protobuf/check_unknown_fields.cc @@ -62,7 +62,7 @@ bool MessageMayContainExtensionsRecursive(const ::google::protobuf::Descriptor* bool MessageMayContainExtensionsMemoized(const ::google::protobuf::Descriptor* descriptor) { static auto* memoized = new MayContainExtensionsMap(); static absl::Mutex lock; - absl::MutexLock l(&lock); + absl::MutexLock l(lock); return MessageMayContainExtensionsRecursive(descriptor, memoized); } @@ -181,7 +181,7 @@ void AllowUnknownFieldsFor(absl::string_view top_message_descriptor_full_name, unknown_field_parent_message_fqn)); } -absl::optional CheckRecursively( +std::optional CheckRecursively( const ::google::protobuf::python::PyProto_API* py_proto_api, const ::google::protobuf::Message* message) { const auto* root_descriptor = message->GetDescriptor(); diff --git a/pybind11_protobuf/proto_cast_util.cc b/pybind11_protobuf/proto_cast_util.cc index ddd81d6..ffbef4b 100644 --- a/pybind11_protobuf/proto_cast_util.cc +++ b/pybind11_protobuf/proto_cast_util.cc @@ -80,7 +80,7 @@ bool IsImportError(py::error_already_set& e) { // Resolves a sequence of python attrs starting from obj. // If any does not exist, returns nullopt. -absl::optional ResolveAttrs( +std::optional ResolveAttrs( py::handle obj, std::initializer_list names) { py::object tmp; for (const char* name : names) { @@ -101,7 +101,8 @@ absl::optional ResolveAttrs( // Unfortunately the metaclass mechanism used by protos (fast_cpp_protos) does // not leave __dict__ in a state where the default getattr functions find the // base class methods, so we resolve those using MRO. -absl::optional ResolveAttrMRO(py::handle obj, const char* name) { +std::optional ResolveAttrMRO(py::handle obj, + const char* name) { PyObject* attr; const auto* t = Py_TYPE(obj.ptr()); if (!t->tp_mro) { @@ -135,7 +136,7 @@ absl::optional ResolveAttrMRO(py::handle obj, const char* name) { return absl::nullopt; } -absl::optional CastToOptionalString(py::handle src) { +std::optional CastToOptionalString(py::handle src) { // Avoid pybind11::cast because it throws an exeption. pybind11::detail::make_caster c; if (c.load(src, false)) { @@ -492,7 +493,7 @@ const Message* PyProtoGetCppMessagePointer(py::handle src) { #endif } -absl::optional PyProtoDescriptorFullName(py::handle py_proto) { +std::optional PyProtoDescriptorFullName(py::handle py_proto) { assert(PyGILState_Check()); auto py_full_name = ResolveAttrs(py_proto, {"DESCRIPTOR", "full_name"}); if (py_full_name) {