| 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 | |
| 590 | LEAN_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 | |
| 597 | static 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); |
no test coverage detected