@@ -61,8 +61,8 @@ namespace {
61
61
// Resolves the class name of a descriptor via d->containing_type()
62
62
py::object ResolveDescriptor (py::object p, const Descriptor* d) {
63
63
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 ()));
66
66
}
67
67
68
68
// Returns true if an exception is an import error.
@@ -266,10 +266,11 @@ py::object GlobalState::PyMessageInstance(const Descriptor* descriptor) {
266
266
}
267
267
}
268
268
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, " ?" ));
273
274
}
274
275
275
276
// Create C++ DescriptorPools based on Python DescriptorPools.
@@ -525,8 +526,9 @@ void CProtoCopyToPyProto(Message* message, py::handle py_proto) {
525
526
assert (PyGILState_Check ());
526
527
auto merge_fn = ResolveAttrMRO (py_proto, " MergeFromString" );
527
528
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 ()));
530
532
}
531
533
532
534
auto serialized = message->SerializePartialAsString ();
0 commit comments