Skip to content

Commit

Permalink
Automated Code Change
Browse files Browse the repository at this point in the history
PiperOrigin-RevId: 672296898
  • Loading branch information
evalon32 authored and copybara-github committed Sep 16, 2024
1 parent f1b2459 commit 4849c9d
Showing 1 changed file with 10 additions and 8 deletions.
18 changes: 10 additions & 8 deletions pybind11_protobuf/proto_cast_util.cc
Original file line number Diff line number Diff line change
Expand Up @@ -61,8 +61,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(d->name().c_str())
: p.attr(d->name().c_str());
.attr(py::str(d->name()))
: p.attr(py::str(d->name()));
}

// Returns true if an exception is an import error.
Expand Down Expand Up @@ -266,10 +266,11 @@ py::object GlobalState::PyMessageInstance(const Descriptor* descriptor) {
}
}

throw py::type_error("Cannot construct a protocol buffer message type " +
descriptor->full_name() +
" in python. Is there a missing dependency on module " +
module_name + "?");
throw py::type_error(
absl::StrCat("Cannot construct a protocol buffer message type ",
descriptor->full_name(),
" in python. Is there a missing dependency on module ",
module_name, "?"));
}

// Create C++ DescriptorPools based on Python DescriptorPools.
Expand Down Expand Up @@ -525,8 +526,9 @@ void CProtoCopyToPyProto(Message* message, py::handle py_proto) {
assert(PyGILState_Check());
auto merge_fn = ResolveAttrMRO(py_proto, "MergeFromString");
if (!merge_fn) {
throw py::type_error("MergeFromString method not found; is this a " +
message->GetDescriptor()->full_name());
throw py::type_error(
absl::StrCat("MergeFromString method not found; is this a ",
message->GetDescriptor()->full_name()));
}

auto serialized = message->SerializePartialAsString();
Expand Down

0 comments on commit 4849c9d

Please sign in to comment.