Skip to content

Commit

Permalink
Breaking change: Remove deprecated GetDebugString() from protobuf pyt…
Browse files Browse the repository at this point in the history
…hon cpp extension.

cpp extension added the API in #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
  • Loading branch information
anandolee authored and copybara-github committed Oct 31, 2024
1 parent f2cf85c commit b6ac718
Show file tree
Hide file tree
Showing 3 changed files with 0 additions and 19 deletions.
7 changes: 0 additions & 7 deletions python/google/protobuf/internal/descriptor_test.py
Original file line number Diff line number Diff line change
Expand Up @@ -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())
Expand Down
10 changes: 0 additions & 10 deletions python/google/protobuf/pyext/descriptor.cc
Original file line number Diff line number Diff line change
Expand Up @@ -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));
}
Expand Down Expand Up @@ -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},
Expand Down
2 changes: 0 additions & 2 deletions python/pb_unit_tests/descriptor_test_wrapper.py
Original file line number Diff line number Diff line change
Expand Up @@ -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)

0 comments on commit b6ac718

Please sign in to comment.