Skip to content

Commit

Permalink
Remove definitions for CanonicalCode(), error_message(), and `get…
Browse files Browse the repository at this point in the history
…_source_location_trace_str()`

PiperOrigin-RevId: 572292285
  • Loading branch information
Matt McDonald authored and copybara-github committed Oct 10, 2023
1 parent ba421f1 commit bced1f0
Show file tree
Hide file tree
Showing 2 changed files with 0 additions and 23 deletions.
20 changes: 0 additions & 20 deletions pybind11_abseil/register_status_bindings.cc
Original file line number Diff line number Diff line change
Expand Up @@ -280,13 +280,6 @@ void RegisterStatusBindings(module m) {
auto output = absl::StrCat(s.message(), " [", code_str, "]");
return decode_utf8_replace(output);
})
.def("get_source_location_trace_str",
[](const absl::Status& s) -> std::string {
if (!s.ok()) {
{};
}
return {};
})
.def_static("OkStatus",
[]() {
handle py_singleton(pybind11_abseil::PyOkStatusSingleton());
Expand All @@ -296,14 +289,6 @@ void RegisterStatusBindings(module m) {
return py_singleton;
})
.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("SetPayload",
[](absl::Status& self, absl::string_view type_url,
Expand Down Expand Up @@ -425,18 +410,13 @@ void RegisterStatusBindings(module m) {
def __str__(self):
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):
if not isinstance(other, StatusNotOk):
return NotImplemented
lhs = Status(InitFromTag.capsule, self._status)
rhs = Status(InitFromTag.capsule, other._status)
return lhs == rhs
# NOTE: The absl::SourceLocation is lost.
# It is impossible to serialize-deserialize.
def __reduce_ex__(self, protocol):
del protocol
return (type(self), (self._status,))
Expand Down
3 changes: 0 additions & 3 deletions pybind11_abseil/tests/status_test.py
Original file line number Diff line number Diff line change
Expand Up @@ -64,16 +64,13 @@ def test_create_ok_status(self):
ok_status = status.Status.OkStatus()
self.assertEqual(ok_status.to_string(), 'OK')
self.assertEqual(ok_status.raw_code(), 0)
self.assertEqual(ok_status.CanonicalCode(), 0)
self.assertEqual(ok_status.error_message(), '')
self.assertIsNone(ok_status.IgnoreError())

def test_error_message_malformed_utf8(self):
malformed_utf8 = b'\x80'
stx80 = status.invalid_argument_error(malformed_utf8)
self.assertEqual(stx80.message(), '�')
self.assertEqual(stx80.message_bytes(), malformed_utf8)
self.assertEqual(stx80.error_message(), '�')
self.assertEqual(stx80.to_string(), 'INVALID_ARGUMENT: �')
self.assertEqual(str(stx80), 'INVALID_ARGUMENT: �')
e = status.StatusNotOk(stx80)
Expand Down

0 comments on commit bced1f0

Please sign in to comment.