Add UPB support for FileDescriptorProto.option_dependency.

This change adds API and implementation to read and write the option_dependency field from/to proto2.FileDescriptorProto in upb reflection.

PiperOrigin-RevId: 947120641
This commit is contained in:
Runze Wang 2026-07-13 10:36:41 -07:00 committed by Copybara-Service
parent 774721742b
commit 4db27e1f33
7 changed files with 49 additions and 10 deletions

View file

@ -40,12 +40,6 @@ class ProtoAPIDescriptorDatabase : public google::protobuf::DescriptorDatabase {
bool FindFileByName(absl::string_view filename,
google::protobuf::FileDescriptorProto* output) override {
if (PyErr_Occurred()) {
// If an error has already occurred, PyObject_CallMethod will assert.
// Reset it so we can continue.
PyErr_Clear();
}
PyObject* pyfile_name =
PyUnicode_FromStringAndSize(filename.data(), filename.size());
if (pyfile_name == nullptr) {
@ -57,8 +51,9 @@ class ProtoAPIDescriptorDatabase : public google::protobuf::DescriptorDatabase {
PyObject_CallMethod(pool_, "FindFileByName", "O", pyfile_name);
Py_DECREF(pyfile_name);
if (pyfile == nullptr) {
PyErr_Format(PyExc_TypeError, "Default python pool fail to find %s",
filename.data());
if (PyErr_ExceptionMatches(PyExc_KeyError)) {
PyErr_Clear();
}
return false;
}