From 8a11c3c8f094c9e8deea6ceef533070390f9dc88 Mon Sep 17 00:00:00 2001 From: Jie Luo Date: Wed, 6 Sep 2023 12:03:08 -0700 Subject: [PATCH] Add python test for deprecated syntax PiperOrigin-RevId: 563175424 --- python/google/protobuf/internal/descriptor_test.py | 1 + upb/python/descriptor.c | 13 +++++++++++++ 2 files changed, 14 insertions(+) diff --git a/python/google/protobuf/internal/descriptor_test.py b/python/google/protobuf/internal/descriptor_test.py index dda15bde66..b29133eba8 100755 --- a/python/google/protobuf/internal/descriptor_test.py +++ b/python/google/protobuf/internal/descriptor_test.py @@ -553,6 +553,7 @@ class DescriptorTest(unittest.TestCase): self.assertEqual(self.my_file.package, 'protobuf_unittest') self.assertEqual(self.my_file.pool, self.pool) self.assertFalse(self.my_file.has_options) + self.assertEqual(self.my_file.syntax, 'proto2') file_proto = descriptor_pb2.FileDescriptorProto() self.my_file.CopyToProto(file_proto) self.assertEqual(self.my_file.serialized_pb, diff --git a/upb/python/descriptor.c b/upb/python/descriptor.c index 9cce8c7751..6697199472 100644 --- a/upb/python/descriptor.c +++ b/upb/python/descriptor.c @@ -639,7 +639,13 @@ static PyGetSetDef PyUpb_Descriptor_Getters[] = { "Containing type"}, {"is_extendable", PyUpb_Descriptor_GetIsExtendable, NULL}, {"has_options", PyUpb_Descriptor_GetHasOptions, NULL, "Has Options"}, + // begin:github_only {"syntax", &PyUpb_Descriptor_GetSyntax, NULL, "Syntax"}, + // end:github_only + // begin:google_only +// // TODO(b/271287872) Use this to open-source syntax deprecation. +// {"deprecated_syntax", &PyUpb_Descriptor_GetSyntax, NULL, "Syntax"}, + // end:google_only {NULL}}; static PyMethodDef PyUpb_Descriptor_Methods[] = { @@ -1328,7 +1334,14 @@ static PyGetSetDef PyUpb_FileDescriptor_Getters[] = { {"public_dependencies", PyUpb_FileDescriptor_GetPublicDependencies, NULL, "Dependencies"}, {"has_options", PyUpb_FileDescriptor_GetHasOptions, NULL, "Has Options"}, + // begin:github_only {"syntax", PyUpb_FileDescriptor_GetSyntax, (setter)NULL, "Syntax"}, + // end:github_only + // begin:google_only +// // TODO(b/271287872) Use this to open-source syntax deprecation. +// {"deprecated_syntax", PyUpb_FileDescriptor_GetSyntax, (setter)NULL, +// "Syntax"}, + // end:google_only {NULL}, };