@@ -61,8 +61,8 @@ namespace {
6161// Resolves the class name of a descriptor via d->containing_type()
6262py::object ResolveDescriptor (py::object p, const Descriptor* d) {
6363 return d->containing_type () ? ResolveDescriptor (p, d->containing_type ())
64- .attr (d->name (). c_str ( ))
65- : p.attr (d->name (). c_str ( ));
64+ .attr (py::str ( d->name ()))
65+ : p.attr (py::str ( d->name ()));
6666}
6767
6868// Returns true if an exception is an import error.
@@ -266,10 +266,11 @@ py::object GlobalState::PyMessageInstance(const Descriptor* descriptor) {
266266 }
267267 }
268268
269- throw py::type_error (" Cannot construct a protocol buffer message type " +
270- descriptor->full_name () +
271- " in python. Is there a missing dependency on module " +
272- module_name + " ?" );
269+ throw py::type_error (
270+ absl::StrCat (" Cannot construct a protocol buffer message type " ,
271+ descriptor->full_name (),
272+ " in python. Is there a missing dependency on module " ,
273+ module_name, " ?" ));
273274}
274275
275276// Create C++ DescriptorPools based on Python DescriptorPools.
@@ -525,8 +526,9 @@ void CProtoCopyToPyProto(Message* message, py::handle py_proto) {
525526 assert (PyGILState_Check ());
526527 auto merge_fn = ResolveAttrMRO (py_proto, " MergeFromString" );
527528 if (!merge_fn) {
528- throw py::type_error (" MergeFromString method not found; is this a " +
529- message->GetDescriptor ()->full_name ());
529+ throw py::type_error (
530+ absl::StrCat (" MergeFromString method not found; is this a " ,
531+ message->GetDescriptor ()->full_name ()));
530532 }
531533
532534 auto serialized = message->SerializePartialAsString ();
0 commit comments