| 694 | if (!tup) return raise_py_error(); |
| 695 | for (size_t i = 0; i < n; i++) { |
| 696 | PyObject *po = unwrap_pyobject(lean_array_get_core(args, i)); |
| 697 | p_Py_IncRef(po); |
| 698 | p_PyTuple_SetItem(tup, (Py_ssize_t)i, po); |
| 699 | } |
| 700 | PyObject *r = p_PyObject_CallObject(unwrap_pyobject(f), tup); |
| 701 | p_Py_DecRef(tup); |
| 702 | return ok_owned_or_err(r); |
| 703 | } |
| 704 | |
| 705 | LEAN_EXPORT lean_obj_res lean_py_call_kw(b_lean_obj_arg f, b_lean_obj_arg args, b_lean_obj_arg kwargs, lean_obj_arg world) { |
| 706 | (void)world; ENSURE_INIT(); WITH_GIL(); |
| 707 | size_t n = lean_array_size(args); |
| 708 | PyObject *tup = p_PyTuple_New((Py_ssize_t)n); |
| 709 | if (!tup) return raise_py_error(); |
| 710 | for (size_t i = 0; i < n; i++) { |
| 711 | PyObject *po = unwrap_pyobject(lean_array_get_core(args, i)); |
| 712 | p_Py_IncRef(po); |
| 713 | p_PyTuple_SetItem(tup, (Py_ssize_t)i, po); |
| 714 | } |
| 715 | size_t kn = lean_array_size(kwargs); |
| 716 | PyObject *d = p_PyDict_New(); |
| 717 | if (!d) { p_Py_DecRef(tup); return raise_py_error(); } |
| 718 | for (size_t i = 0; i < kn; i++) { |
| 719 | lean_object *kv = lean_array_get_core(kwargs, i); |
| 720 | lean_object *key = lean_ctor_get(kv, 0); |
| 721 | lean_object *val = lean_ctor_get(kv, 1); |
| 722 | if (p_PyDict_SetItemString(d, lean_string_cstr(key), unwrap_pyobject(val)) != 0) { |
| 723 | p_Py_DecRef(d); p_Py_DecRef(tup); |
| 724 | return raise_py_error(); |
| 725 | } |
nothing calls this directly
no test coverage detected