Allocate a LeanCallableObject of the given variant and bind the closure * (transferring ownership). Wraps the resulting Python object as a Lean * `Py` via wrap_pyobject so the Lean side sees it as just another Py. */
| 1021 | "Lean closure returned a NULL Py object"); |
| 1022 | } |
| 1023 | return NULL; |
| 1024 | } |
| 1025 | return out; |
| 1026 | } |
| 1027 | |
| 1028 | /* Allocate a LeanCallableObject of the given variant and bind the closure |
| 1029 | * (transferring ownership). Wraps the resulting Python object as a Lean |
| 1030 | * `Py` via wrap_pyobject so the Lean side sees it as just another Py. */ |
| 1031 | static lean_object *make_callable_obj(lean_obj_arg closure, int has_kw) { |
| 1032 | if (!py_initialized) { |
| 1033 | lean_dec(closure); |
| 1034 | return raise_io_error( |
| 1035 | "LeanPy.Python.Py.fromLeanCallable: Python not initialized; " |
| 1036 | "call LeanPy.Python.init first"); |
| 1037 | } |
| 1038 | PyObject *type = get_lean_callable_type(has_kw); |
| 1039 | if (!type) { |
| 1040 | lean_dec(closure); |
| 1041 | return raise_io_error( |
| 1042 | "LeanPy.Python.Py.fromLeanCallable: failed to create type"); |
| 1043 | } |
| 1044 | PyObject *instance = p_PyType_GenericAlloc(type, 0); |
| 1045 | if (!instance) { |
| 1046 | lean_dec(closure); |
| 1047 | return raise_py_error(); |
| 1048 | } |
no test coverage detected