| 178 | } |
| 179 | |
| 180 | std::vector<std::byte> py_bytes_as_vec(PyObject *bytes) |
| 181 | { |
| 182 | assert(bytes); |
| 183 | assert(PyBytes_CheckExact(bytes)); |
| 184 | Py_ssize_t length; |
| 185 | char *buf; |
| 186 | int r = PyBytes_AsStringAndSize( |
| 187 | bytes, &buf, &length); |
| 188 | assert(r == 0); |
| 189 | return std::vector<std::byte>{ |
| 190 | reinterpret_cast<const std::byte*>(buf), |
| 191 | reinterpret_cast<const std::byte*>(buf) + size_t(length)}; |
| 192 | } |
| 193 | |
| 194 | PyObject *py_bytes_from_vec(const std::vector<std::byte> &s) |
| 195 | { |
no test coverage detected