You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
I'm using Dl.dlopen from the ctypes.foreign package to load a collection of C functions which use the Python C API. As such, coming from OCaml and pyml, I need a way to call a C function and pass it a naked PyObject * . If I use Pycaml.pyunwrap_value I get a type error.
More specifically, I have:
Py.initialize ();
let globals = Py.Module.get_dict (Py.Module.main ()) in
let open Ctypes in
let c_set_item = Dl.(dlopen ~filename:"c_py_set_item.so" ~flags:[RTLD_NOW]) in
let my_set_item_int = Foreign.foreign ~from:c_set_item "my_set_item_int" (ptr void @-> string @-> int @-> returning void) in
let _ = my_set_item_int (Pycaml.pyunwrap_value globals) "my_variable" 4 in
This yields the error pyml_unwrap_value: type mismatch from within pyml_stubs.c as the extracted pointer is coming from the wrong type of Python capsule.
Any suggestions on how to get this to go through? Should I be using something other than Pycaml.pyunwrap_value?
The text was updated successfully, but these errors were encountered:
Great job with this package!
I'm using
Dl.dlopen
from thectypes.foreign
package to load a collection of C functions which use the Python C API. As such, coming from OCaml and pyml, I need a way to call a C function and pass it a nakedPyObject *
. If I usePycaml.pyunwrap_value
I get a type error.More specifically, I have:
and the following mundane C code:
This yields the error
pyml_unwrap_value: type mismatch
from withinpyml_stubs.c
as the extracted pointer is coming from the wrong type of Python capsule.Any suggestions on how to get this to go through? Should I be using something other than
Pycaml.pyunwrap_value
?The text was updated successfully, but these errors were encountered: