| 513 | size_t n = lean_string_size(s) - 1; /* size includes terminating NUL */ |
| 514 | return ok_owned_or_err(p_PyUnicode_DecodeUTF8(cs, (Py_ssize_t)n, NULL)); |
| 515 | } |
| 516 | |
| 517 | LEAN_EXPORT lean_obj_res lean_py_of_bytes(b_lean_obj_arg ba, lean_obj_arg world) { |
| 518 | (void)world; ENSURE_INIT(); WITH_GIL(); |
| 519 | Py_ssize_t n = (Py_ssize_t) lean_sarray_size(ba); |
| 520 | const char *p = (const char *) lean_sarray_cptr(ba); |
| 521 | return ok_owned_or_err(p_PyBytes_FromStringAndSize(p, n)); |
| 522 | } |
| 523 | |
| 524 | LEAN_EXPORT lean_obj_res lean_py_of_list(b_lean_obj_arg arr, lean_obj_arg world) { |
| 525 | (void)world; ENSURE_INIT(); WITH_GIL(); |
| 526 | size_t n = lean_array_size(arr); |
| 527 | PyObject *list = p_PyList_New((Py_ssize_t)n); |
| 528 | if (!list) return raise_py_error(); |
| 529 | for (size_t i = 0; i < n; i++) { |
| 530 | lean_object *elem = lean_array_get_core(arr, i); |
nothing calls this directly
no test coverage detected