Commit 55db5e0b by pybind11_abseil authors Committed by Copybara-Service

internal change.

PiperOrigin-RevId: 509255012
parent 38b42686
...@@ -146,7 +146,6 @@ handle PyStatusNotOkTypeInUse() { ...@@ -146,7 +146,6 @@ handle PyStatusNotOkTypeInUse() {
type_in_use = object(module_in_use.attr("StatusNotOk")).release(); type_in_use = object(module_in_use.attr("StatusNotOk")).release();
return type_in_use; return type_in_use;
} }
} // namespace } // namespace
namespace internal { namespace internal {
...@@ -278,8 +277,15 @@ void RegisterStatusBindings(module m) { ...@@ -278,8 +277,15 @@ void RegisterStatusBindings(module m) {
// assumption is violated. // assumption is violated.
code_str = std::to_string(static_cast<int>(s.code())); code_str = std::to_string(static_cast<int>(s.code()));
} }
return decode_utf8_replace( auto output = absl::StrCat(s.message(), " [", code_str, "]");
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", .def_static("OkStatus",
[]() { []() {
...@@ -419,6 +425,9 @@ void RegisterStatusBindings(module m) { ...@@ -419,6 +425,9 @@ 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
......
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