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
| 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. */ |
| 251 | LEAN_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 */ |
nothing calls this directly
no test coverage detected