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

Function py_obj_to_lean_string

LeanPy/native/python_bridge.c:588–598  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

586 if (v == -1 && p_PyErr_Occurred()) return raise_py_error();
587 return lean_io_result_mk_ok(lean_int64_to_int((int64_t) v));
588}
589
590LEAN_EXPORT lean_obj_res lean_py_to_float(b_lean_obj_arg p, lean_obj_arg world) {
591 (void)world; ENSURE_INIT(); WITH_GIL();
592 double d = p_PyFloat_AsDouble(unwrap_pyobject(p));
593 if (d == -1.0 && p_PyErr_Occurred()) return raise_py_error();
594 return lean_io_result_mk_ok(lean_box_float(d));
595}
596
597static lean_object *py_obj_to_lean_string(PyObject *s) {
598 if (!s) return raise_py_error();
599 const char *cs = p_PyUnicode_AsUTF8(s);
600 if (!cs) {
601 p_Py_DecRef(s);

Callers 4

lean_py_to_stringFunction · 0.85
lean_py_reprFunction · 0.85
lean_py_strFunction · 0.85
lean_py_type_nameFunction · 0.85

Calls 1

raise_py_errorFunction · 0.85

Tested by

no test coverage detected