* Get the single-line exception message, without clearing any * exception state. */
| 144 | * exception state. |
| 145 | */ |
| 146 | std::string peek_pyerror() |
| 147 | { |
| 148 | PyObject *ptype, *pvalue, *ptraceback; |
| 149 | PyErr_Fetch(&ptype, &pvalue, &ptraceback); |
| 150 | ceph_assert(ptype); |
| 151 | ceph_assert(pvalue); |
| 152 | PyObject *pvalue_str = PyObject_Str(pvalue); |
| 153 | std::string exc_msg = PyUnicode_AsUTF8(pvalue_str); |
| 154 | Py_DECREF(pvalue_str); |
| 155 | PyErr_Restore(ptype, pvalue, ptraceback); |
| 156 | |
| 157 | return exc_msg; |
| 158 | } |
| 159 | |
| 160 | std::span<std::byte const> py_bytes_as_span(PyObject *bytes) |
| 161 | { |
no outgoing calls
no test coverage detected