summaryrefslogtreecommitdiffstats
path: root/contrib/python/protobuf
diff options
context:
space:
mode:
authorpg <[email protected]>2024-03-27 20:45:52 +0300
committerpg <[email protected]>2024-03-27 20:59:16 +0300
commit0a9f70229b9ddccbd4a09d389642ddafcbe8fd57 (patch)
tree31883a3cee60b7c9c373dbdf745490574788b2b0 /contrib/python/protobuf
parent01e2f64ea9b0a11884d483b296278f0811c33d92 (diff)
2594c64e637fd7028000c2f6e9c69b8554b86a5b
Diffstat (limited to 'contrib/python/protobuf')
-rw-r--r--contrib/python/protobuf/py2/google/protobuf/pyext/descriptor_pool.cc35
-rw-r--r--contrib/python/protobuf/py2/ya.make50
2 files changed, 48 insertions, 37 deletions
diff --git a/contrib/python/protobuf/py2/google/protobuf/pyext/descriptor_pool.cc b/contrib/python/protobuf/py2/google/protobuf/pyext/descriptor_pool.cc
index a53411e797a..3c08de1dc0f 100644
--- a/contrib/python/protobuf/py2/google/protobuf/pyext/descriptor_pool.cc
+++ b/contrib/python/protobuf/py2/google/protobuf/pyext/descriptor_pool.cc
@@ -592,31 +592,40 @@ static PyObject* AddSerializedFile(PyObject* pself, PyObject* serialized_pb) {
PyErr_SetString(PyExc_TypeError, "Couldn't parse file content!");
return NULL;
}
-
+ // DescriptorPool::InternalAddGeneratedFile(message_type, message_len);
// If the file was already part of a C++ library, all its descriptors are in
// the underlying pool. No need to do anything else.
const FileDescriptor* generated_file = NULL;
if (self->underlay) {
generated_file = self->underlay->FindFileByName(file_proto.name());
}
+
if (generated_file != NULL) {
- return PyFileDescriptor_FromDescriptorWithSerializedPb(
- generated_file, serialized_pb);
+ return PyFileDescriptor_FromDescriptorWithSerializedPb(generated_file, serialized_pb);
}
BuildFileErrorCollector error_collector;
- const FileDescriptor* descriptor =
- self->pool->BuildFileCollectingErrors(file_proto,
- &error_collector);
- if (descriptor == NULL) {
- PyErr_Format(PyExc_TypeError,
- "Couldn't build proto file into descriptor pool!\n%s",
- error_collector.error_message.c_str());
- return NULL;
+
+ generated_file = self->pool->BuildFileCollectingErrors(file_proto, &error_collector);
+
+ if (generated_file != NULL) {
+ return PyFileDescriptor_FromDescriptorWithSerializedPb(generated_file, serialized_pb);
+ }
+
+ DescriptorPool::InternalAddGeneratedFile(message_type, message_len);
+
+ if (self->underlay) {
+ generated_file = self->underlay->FindFileByName(file_proto.name());
+ }
+
+ if (generated_file != NULL) {
+ return PyFileDescriptor_FromDescriptorWithSerializedPb(generated_file, serialized_pb);
}
- return PyFileDescriptor_FromDescriptorWithSerializedPb(
- descriptor, serialized_pb);
+ PyErr_Format(PyExc_TypeError,
+ "Couldn't build proto file into descriptor pool!\n%s",
+ error_collector.error_message.c_str());
+ return NULL;
}
static PyObject* Add(PyObject* self, PyObject* file_descriptor_proto) {
diff --git a/contrib/python/protobuf/py2/ya.make b/contrib/python/protobuf/py2/ya.make
index c66515d586b..7cb63736ef6 100644
--- a/contrib/python/protobuf/py2/ya.make
+++ b/contrib/python/protobuf/py2/ya.make
@@ -9,41 +9,22 @@ VERSION(3.17.3)
ORIGINAL_SOURCE(https://github.com/protocolbuffers/protobuf/archive/v3.17.3.tar.gz)
PEERDIR(
- contrib/libs/protobuf
- contrib/libs/protobuf/builtin_proto/protos_from_protobuf
- contrib/libs/protobuf/builtin_proto/protos_from_protoc
+ contrib/libs/protobuf_old
+ contrib/libs/protobuf_old/builtin_proto/protos_from_protobuf
+ #contrib/libs/protobuf_old/builtin_proto/protos_from_protoc
contrib/python/six
)
ADDINCL(
contrib/python/protobuf/py2
+ contrib/libs/protobuf_old
+ contrib/libs/protobuf_old/src
)
NO_COMPILER_WARNINGS()
NO_LINT()
-CFLAGS(
- -DPYTHON_PROTO2_CPP_IMPL_V2
-)
-
-SRCS(
- google/protobuf/internal/api_implementation.cc
- google/protobuf/pyext/descriptor.cc
- google/protobuf/pyext/descriptor_containers.cc
- google/protobuf/pyext/descriptor_database.cc
- google/protobuf/pyext/descriptor_pool.cc
- google/protobuf/pyext/extension_dict.cc
- google/protobuf/pyext/field.cc
- google/protobuf/pyext/map_container.cc
- google/protobuf/pyext/message.cc
- google/protobuf/pyext/message_factory.cc
- google/protobuf/pyext/message_module.cc
- google/protobuf/pyext/repeated_composite_container.cc
- google/protobuf/pyext/repeated_scalar_container.cc
- google/protobuf/pyext/unknown_fields.cc
-)
-
PY_REGISTER(
google.protobuf.internal._api_implementation
google.protobuf.pyext._message
@@ -85,4 +66,25 @@ PY_SRCS(
google/protobuf/util/__init__.py
)
+CFLAGS(
+ -DPYTHON_PROTO2_CPP_IMPL_V2
+)
+
+SRCS(
+ google/protobuf/internal/api_implementation.cc
+ google/protobuf/pyext/descriptor.cc
+ google/protobuf/pyext/descriptor_containers.cc
+ google/protobuf/pyext/descriptor_database.cc
+ google/protobuf/pyext/descriptor_pool.cc
+ google/protobuf/pyext/extension_dict.cc
+ google/protobuf/pyext/field.cc
+ google/protobuf/pyext/map_container.cc
+ google/protobuf/pyext/message.cc
+ google/protobuf/pyext/message_factory.cc
+ google/protobuf/pyext/message_module.cc
+ google/protobuf/pyext/repeated_composite_container.cc
+ google/protobuf/pyext/repeated_scalar_container.cc
+ google/protobuf/pyext/unknown_fields.cc
+)
+
END()