Commit bced1f03 by Matt McDonald Committed by Copybara-Service

Remove definitions for `CanonicalCode()`, `error_message()`, and `get_source_location_trace_str()`

PiperOrigin-RevId: 572292285
parent ba421f11
...@@ -280,13 +280,6 @@ void RegisterStatusBindings(module m) { ...@@ -280,13 +280,6 @@ void RegisterStatusBindings(module m) {
auto output = absl::StrCat(s.message(), " [", code_str, "]"); auto output = absl::StrCat(s.message(), " [", code_str, "]");
return decode_utf8_replace(output); return decode_utf8_replace(output);
}) })
.def("get_source_location_trace_str",
[](const absl::Status& s) -> std::string {
if (!s.ok()) {
{};
}
return {};
})
.def_static("OkStatus", .def_static("OkStatus",
[]() { []() {
handle py_singleton(pybind11_abseil::PyOkStatusSingleton()); handle py_singleton(pybind11_abseil::PyOkStatusSingleton());
...@@ -296,14 +289,6 @@ void RegisterStatusBindings(module m) { ...@@ -296,14 +289,6 @@ void RegisterStatusBindings(module m) {
return py_singleton; return py_singleton;
}) })
.def("raw_code", &absl::Status::raw_code) .def("raw_code", &absl::Status::raw_code)
.def("CanonicalCode",
[](const absl::Status& self) {
return static_cast<int>(self.code());
})
.def("error_message",
[](const absl::Status& self) {
return decode_utf8_replace(self.message());
})
.def("IgnoreError", &absl::Status::IgnoreError) .def("IgnoreError", &absl::Status::IgnoreError)
.def("SetPayload", .def("SetPayload",
[](absl::Status& self, absl::string_view type_url, [](absl::Status& self, absl::string_view type_url,
...@@ -425,9 +410,6 @@ void RegisterStatusBindings(module m) { ...@@ -425,9 +410,6 @@ void RegisterStatusBindings(module m) {
def __str__(self): def __str__(self):
return self._status.status_not_ok_str() return self._status.status_not_ok_str()
def get_source_location_trace_str(self):
return self._status.get_source_location_trace_str()
def __eq__(self, other): def __eq__(self, other):
if not isinstance(other, StatusNotOk): if not isinstance(other, StatusNotOk):
return NotImplemented return NotImplemented
...@@ -435,8 +417,6 @@ void RegisterStatusBindings(module m) { ...@@ -435,8 +417,6 @@ void RegisterStatusBindings(module m) {
rhs = Status(InitFromTag.capsule, other._status) rhs = Status(InitFromTag.capsule, other._status)
return lhs == rhs return lhs == rhs
# NOTE: The absl::SourceLocation is lost.
# It is impossible to serialize-deserialize.
def __reduce_ex__(self, protocol): def __reduce_ex__(self, protocol):
del protocol del protocol
return (type(self), (self._status,)) return (type(self), (self._status,))
......
...@@ -64,8 +64,6 @@ class StatusTest(parameterized.TestCase): ...@@ -64,8 +64,6 @@ class StatusTest(parameterized.TestCase):
ok_status = status.Status.OkStatus() ok_status = status.Status.OkStatus()
self.assertEqual(ok_status.to_string(), 'OK') self.assertEqual(ok_status.to_string(), 'OK')
self.assertEqual(ok_status.raw_code(), 0) self.assertEqual(ok_status.raw_code(), 0)
self.assertEqual(ok_status.CanonicalCode(), 0)
self.assertEqual(ok_status.error_message(), '')
self.assertIsNone(ok_status.IgnoreError()) self.assertIsNone(ok_status.IgnoreError())
def test_error_message_malformed_utf8(self): def test_error_message_malformed_utf8(self):
...@@ -73,7 +71,6 @@ class StatusTest(parameterized.TestCase): ...@@ -73,7 +71,6 @@ class StatusTest(parameterized.TestCase):
stx80 = status.invalid_argument_error(malformed_utf8) stx80 = status.invalid_argument_error(malformed_utf8)
self.assertEqual(stx80.message(), '�') self.assertEqual(stx80.message(), '�')
self.assertEqual(stx80.message_bytes(), malformed_utf8) self.assertEqual(stx80.message_bytes(), malformed_utf8)
self.assertEqual(stx80.error_message(), '�')
self.assertEqual(stx80.to_string(), 'INVALID_ARGUMENT: �') self.assertEqual(stx80.to_string(), 'INVALID_ARGUMENT: �')
self.assertEqual(str(stx80), 'INVALID_ARGUMENT: �') self.assertEqual(str(stx80), 'INVALID_ARGUMENT: �')
e = status.StatusNotOk(stx80) e = status.StatusNotOk(stx80)
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment