From 0daec85b6b1b56ef366b1c59bb7a55e92f787db8 Mon Sep 17 00:00:00 2001 From: Jie Luo Date: Tue, 15 Oct 2024 12:07:39 -0700 Subject: [PATCH] Breaking change: Remove deprecated GetDebugString() from protobuf python cpp extension. cpp extension added the API in https://github.com/protocolbuffers/protobuf/pull/7498 Pure python and upb do not support it and filtered out the test This API does not exists in any other language except C++. PiperOrigin-RevId: 686192076 --- python/google/protobuf/internal/descriptor_test.py | 7 ------- python/google/protobuf/pyext/descriptor.cc | 10 ---------- python/pb_unit_tests/descriptor_test_wrapper.py | 2 -- 3 files changed, 19 deletions(-) diff --git a/python/google/protobuf/internal/descriptor_test.py b/python/google/protobuf/internal/descriptor_test.py index 7c6ad14714bda..134c36586a901 100755 --- a/python/google/protobuf/internal/descriptor_test.py +++ b/python/google/protobuf/internal/descriptor_test.py @@ -236,13 +236,6 @@ def testContainingTypeFixups(self): def testContainingServiceFixups(self): self.assertEqual(self.my_service, self.my_method.containing_service) - @unittest.skipIf( - api_implementation.Type() == 'python', - 'GetDebugString is only available with the cpp implementation', - ) - def testGetDebugString(self): - self.assertEqual(self.my_file.GetDebugString(), TEST_FILE_DESCRIPTOR_DEBUG) - def testGetOptions(self): self.assertEqual(self.my_enum.GetOptions(), descriptor_pb2.EnumOptions()) diff --git a/python/google/protobuf/pyext/descriptor.cc b/python/google/protobuf/pyext/descriptor.cc index c4b9f5e2dda5a..767a86f0a0209 100644 --- a/python/google/protobuf/pyext/descriptor.cc +++ b/python/google/protobuf/pyext/descriptor.cc @@ -1512,15 +1512,6 @@ static int SetHasOptions(PyFileDescriptor *self, PyObject *value, return CheckCalledFromGeneratedFile("has_options"); } -static PyObject* GetDebugString(PyFileDescriptor* self) { - PyErr_Warn(nullptr, - "GetDebugString() API is deprecated. This API only " - "exists in protobuf c++ and does not exists in pure python, upb " - "or any other languages. GetDebugString() for python cpp " - "extension will be removed in Jan 2025"); - return PyString_FromCppString(_GetDescriptor(self)->DebugString()); -} - static PyObject* GetOptions(PyFileDescriptor *self) { return GetOrBuildOptions(_GetDescriptor(self)); } @@ -1569,7 +1560,6 @@ static PyGetSetDef Getters[] = { }; static PyMethodDef Methods[] = { - {"GetDebugString", (PyCFunction)GetDebugString, METH_NOARGS}, {"GetOptions", (PyCFunction)GetOptions, METH_NOARGS}, {"_GetFeatures", (PyCFunction)GetFeatures, METH_NOARGS}, {"CopyToProto", (PyCFunction)CopyToProto, METH_O}, diff --git a/python/pb_unit_tests/descriptor_test_wrapper.py b/python/pb_unit_tests/descriptor_test_wrapper.py index b2be7cd3b306a..3b49caf163824 100644 --- a/python/pb_unit_tests/descriptor_test_wrapper.py +++ b/python/pb_unit_tests/descriptor_test_wrapper.py @@ -35,7 +35,5 @@ # Our error message is better. NewDescriptorTest.testImmutableCppDescriptor.__unittest_expecting_failure__ = True -DescriptorTest.testGetDebugString.__unittest_expecting_failure__ = True - if __name__ == '__main__': unittest.main(verbosity=2)