aboutsummaryrefslogtreecommitdiffstats
path: root/contrib/python
diff options
context:
space:
mode:
authorspreis <spreis@yandex-team.com>2024-03-29 14:18:43 +0300
committerspreis <spreis@yandex-team.com>2024-03-29 14:31:49 +0300
commitf39261a434c46274b5eaef0927ee3b2e0d95b41a (patch)
treee64c68742b1a7423d8b2809a5ca938f5ddbed2e2 /contrib/python
parent9334caaba1f032fa294d74e7a74157e3fb263a3e (diff)
downloadydb-f39261a434c46274b5eaef0927ee3b2e0d95b41a.tar.gz
Re-enable separation of protobufs for Python 2 and Python 3
Это откат коммита https://a.yandex-team.ru/arcadia/commit/rXXXXXX И соответственно возврат коммитов https://a.yandex-team.ru/arcadia/commit/rXXXXXX и https://a.yandex-team.ru/arcadia/commit/rXXXXXX Починка причины отката влилась здесь: https://a.yandex-team.ru/arcadia/commit/rXXXXXX ae529e54d3ef7992b0e9f152373bc300061c1293
Diffstat (limited to 'contrib/python')
-rw-r--r--contrib/python/protobuf/py2/google/protobuf/pyext/descriptor_pool.cc35
-rw-r--r--contrib/python/protobuf/py2/ya.make52
2 files changed, 50 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 a53411e797..3c08de1dc0 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 c66515d586..b369e9bf4b 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,27 @@ PY_SRCS(
google/protobuf/util/__init__.py
)
+NO_LTO()
+
+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()