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}, };