MCPcopy Create free account
hub / github.com/BasisResearch/lean.py / leanpy_unwrap_pyobject

Function leanpy_unwrap_pyobject

LeanPy/native/python_bridge.c:251–258  ·  view source on GitHub ↗

Python-side helper: extract the wrapped `PyObject*` from a Lean * external-class handle. Bumps the Python refcount so the caller * receives an owned reference. The Lean handle's own reference is * untouched. Returns NULL if `obj` is not a wrapped PyObject (e.g. * a different external class, or initialisation hasn't happened). * * Used by `lean_py.marshal` to convert a `Py` handle returned fr

Source from the content-addressed store, hash-verified

249 * Used by `lean_py.marshal` to convert a `Py` handle returned from
250 * Lean into a live Python object the caller can use directly. */
251LEAN_EXPORT void * leanpy_unwrap_pyobject(b_lean_obj_arg obj) {
252 if (!py_initialized) return NULL;
253 if (!lean_is_external(obj)) return NULL;
254 PyObject *o = unwrap_pyobject(obj);
255 if (!o) return NULL;
256 p_Py_IncRef(o);
257 return (void *)o;
258}
259
260/* ------------------------------------------------------------------ */
261/* Error mapping */

Callers

nothing calls this directly

Calls 2

lean_is_externalFunction · 0.85
unwrap_pyobjectFunction · 0.85

Tested by

no test coverage detected