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: 691870623
pull/19046/head
Jie Luo 4 weeks ago committed by Copybara-Service
parent f2cf85c941
commit 721a45265b
  1. 7
      python/google/protobuf/internal/descriptor_test.py
  2. 10
      python/google/protobuf/pyext/descriptor.cc
  3. 2
      python/pb_unit_tests/descriptor_test_wrapper.py

@ -236,13 +236,6 @@ class DescriptorTest(unittest.TestCase):
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())

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

@ -35,7 +35,5 @@ import unittest
# Our error message is better.
NewDescriptorTest.testImmutableCppDescriptor.__unittest_expecting_failure__ = True
DescriptorTest.testGetDebugString.__unittest_expecting_failure__ = True
if __name__ == '__main__':
unittest.main(verbosity=2)

Loading…
Cancel
Save