| 158 | } |
| 159 | |
| 160 | std::span<std::byte const> py_bytes_as_span(PyObject *bytes) |
| 161 | { |
| 162 | assert(bytes); |
| 163 | assert(PyBytes_CheckExact(bytes)); |
| 164 | Py_ssize_t length; |
| 165 | char *buf; |
| 166 | int r = PyBytes_AsStringAndSize( |
| 167 | bytes, &buf, &length); |
| 168 | assert(r == 0); |
| 169 | return std::span<std::byte const>((const std::byte*)buf, size_t(length)); |
| 170 | } |
| 171 | |
| 172 | PyObject *py_bytes_from_span(std::span<std::byte const> s) |
| 173 | { |
no test coverage detected